Re: Getting Error "invalid syntax" in Python
For handling the exceptions, the Handling Exceptions are used. It is possible to write programs that handle selected exceptions. I have provided you with an example which asks the user for input until a valid integer has been entered, but allows the user to interrupt the program. You will understand if you look at the following example :
Code:
>>> while True:
try:
x = int(raw_input("Please enter a number: "))
break
except ValueError:
print "That was not a valid number. You will have to try again..."
I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.
Bookmarks