Python program to Check for Non-Existence of Number

x = 210
y = 130
z = 240
value = input("Insert variable x,y,z only: ")
try:
 exec("print("+value+")")
except NameError:
 print("Incorrect variable name!")

 

 

 

Output:

 

Insert variable x,y,z only: y
130

Insert variable x,y,z only: a
Incorrect variable name!

   

 

Subscribe For Daily Updates