i’m using python 3.2.3 idle
here’s my code:
number = input("please enter 1 or 2")
if number != 1 or 2: #this part is wrong
print("You didn't enter 1 or 2")
my code is incorrect. i want to make it so that if the user doesn’t enter 1 or 2, error pops up. say they enter 1.5, 3, etc or something that isn’t 1.0 or 2.0.
how do i do that using the != command?
The problem is that the code is parsed as
and
2, being nonzero, is always True.Instead I would suggest