Handling Exceptions : Value Error : Exception PYTHON examples


PYTHON examples » Exception » Value Error »

 

Handling Exceptions


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 Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Exception
» Value Error