try/except/else : Try « Language Basics « Python






try/except/else

try/except/else

# 
try:
    num = float(raw_input("\nEnter a number: "))
except(ValueError):
    print "That was not a number!"
else:
    print "You entered the number", num     

           
       








Related examples in the same category

1.Nested try and catchNested try and catch