Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python try and except

# Think you want a number from the user
# If the user enters the number correctly it will run the try statement
# if the user enters something else it will run the except statement
number = input('Please enter the number: ')
try:
    user_number = int(number)
    print('You have entered number:', user_number)
except:
    print('The number you have entered is not correct.')
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
1+2 =