Handling Exceptions: Asks the user for input until a valid integer has been entered : Value Error « Exception « Python






Handling Exceptions: Asks the user for input until a valid integer has been entered

Handling Exceptions: Asks the user for input until a valid integer has been entered

while True:
     try:
         x = int(raw_input("Please enter a number: "))
         break
     except ValueError:
         print "Oops!  That was no valid number.  Try again..."

           
       








Related examples in the same category