Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python check if input() gives error

try:
    # Note: Python 2.x users should use raw_input, the equivalent of 3.x's input
    age = int(input("Please enter your age: "))
except ValueError:
    print("Sorry, I didn't understand that.")
else:
	if age >= 18: 
    	print("You are able to vote in the United States!")
	else:
    	print("You are not able to vote in the United States.")
Comment

PREVIOUS NEXT
Code Example
Python :: rename column by indexing 
Python :: creating class and object in python 
Python :: addition of array in python with input 
Python :: check django version windows 
Python :: train_test_split from sklearn.selection 
Python :: how to install python library 
Python :: datetime from float python 
Python :: Dictionary convert 2 lists into a dictionary, use zip() 
Python :: message handler python telegram bot example 
Python :: python undefined 
Python :: cursor.fetchall() to list 
Python :: python for in for in 
Python :: python sort multiple keys 
Python :: sns boxplot 
Python :: how to login using email in django 
Python :: How to develop a UDP echo client? 
Python :: Python Datetime Get year, month, hour, minute, and timestamp 
Python :: get key from value dictionary py 
Python :: spark.read.load 
Python :: appending objects to a list contained in a dictionary python 
Python :: how to add list as new row to pandas dataframe 
Python :: pandas divide multiple columns by one column 
Python :: scree plot sklearn 
Python :: lists to dictionary python 
Python :: get operator as input in python 
Python :: input code for python 
Python :: python list input print 
Python :: flask form 
Python :: how to make a bill in python 
Python :: digital differential analyzer 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =