try/except block that checks for correct user input : Except : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » Except »

 

try/except block that checks for correct user input


try:
    x = raw_input("Enter an integer: ")
    y = int(x)
    print "Your number was", y
except (TypeError, ValueError):
    print "That didn't look like an integer to me."



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Statement
» Except