I am trying to test if my user input is a string or an integer.
feet = input ("Enter your feet.")
inches = input ("Enter your inches.")
if type(eval(feet)) and type(eval(inches)) == int:
print ("both are numbers!")
else:
print ("That's not a Number!")
Here is my code, it works if I enter numbers for the values for feet and inches. However, if feet = a I get an error stating that a is undefined.
What am I doing wrong?
if type(eval(feet)) and type(eval(inches)) == intmeansif bool(type(eval(feet))) and (type(eval(inches)) == int). It does not meanif type(eval(feet)) == int and type(eval(inches)) == int.x and y == zmeansbool(x) and (y == z)not(x == z) and (y == z)If you need to test multiple items you can doall(item==z for item in (x, y)). If you need all items to be the same you can do{x, y} == {z}.