I am new to python , i am confused with this syntax , please help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: I am new to python , i am confused with this syntax , please help (/thread-11963.html) |
I am new to python , i am confused with this syntax , please help - aankrose - Aug-02-2018 Below are the script i have executed and i don't know what the issue is , please help value = eval(input("Please enter an integer value in the range 0...10: ") if value >= 0 and value <= 10: print("In range") print("Done") Error if value >= 0 and value <= 10: ^ SyntaxError: invalid syntax Process finished with exit code 1 Never mind , i got the answer RE: I am new to python , i am confused with this syntax , please help - Axel_Erfurt - Aug-02-2018 value = int(input("Please enter an integer value in the range 0...10: ")) if value >= 0 and value <= 10: print("In range") else: print("Not in range") print("Done") RE: I am new to python , i am confused with this syntax , please help - DeaD_EyE - Aug-02-2018 if value >= 0 and value <= 10:You can write this in a nicer way: if 0 <= value <= 10:The error was in the first line. A missing parenthesis. Don't use eval together with user input. User input is always evil! Don't trust it blind. eval executes expressions like shutil.rmtree('/home/user/').eval does not execute statements. So eval('import os') throws an exception.More dangerous and powerful is exec , which executes also statements.
RE: I am new to python , i am confused with this syntax , please help - aankrose - Aug-03-2018 i got it now and Thank you very much for your response and suggestion |