Python Forum

Full Version: Hello,Guys!,I met a very strange bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
#I am learning Python now ,I have some experience about C#,VB,C.
#The scripture is very easy but I just dont know what's wrong

def eval_loop():
     while True:
        x = input('> ')
        if x== 'done':
            break
        result = eval(x)
        print (result)
eval_loop
#OK that's all code,the problem is it doesnt work, but when I delete def eval_loop(): and eval_loop then it can work.when I use debuging what ever i press F5,F6,F7(IDE Eclipse Version: Oxygen.2 Release (4.7.2)),the weird thing happen,I set break point on the line of def eval_loop():and while True: but the debuging just stop at def line dont stop at after lines until eval_loop.
#So What should I do?Please tell thanks.
Please post your code in Python code tags. You can find help here.
you need line8 to be
eval_loop()
i.e. you miss parenthesis to actually execute the eval_loop function
What happens when you run the script in the terminal?

(Jan-26-2018, 10:06 AM)buran Wrote: [ -> ]you need line8 to be
eval_loop()
i.e. you miss parenthesis to actually execute the eval_loop function

I somehow missed that.

Where so many people learn to use eval with input?! Dodgy
Wow,thank you all you guys,I never expect there are those many people response my question.
Thank you buran,and every one wanna help me.
This is really help me to solve the problem.
ever_loop()
yeah that is exactly what I need.