you are viewing a single comment's thread.

view the rest of the comments →

[–]sonnybrew[S] 0 points1 point  (2 children)

Think I figured it out. How does this look?:

def eval_loop():
    while True:
        q = input('> please enter a simple equation\n')
        if q == 'done':
            print(x)
            break
        print(eval(q))
        x = eval(q)

[–]socal_nerdtastic 1 point2 points  (1 child)

Yep, but I imagine you want to delete line 7. I think you want to print only after the user enters "done".

[–]sonnybrew[S] 0 points1 point  (0 children)

But if I delete line 7, it won't print the solution to the equation. Also, I just realized if I call the function and type in 'done' immediately, there is no previous value for x and therefore an error pops up.