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!
100+ Python Pattern Examples