For example, I want to run the loop when choice
isn't neither1
nor 2
. So my code is like this:
choice = int(input('Enter a number: '))
while choice != 1 or choice != 2:
# some code here
Now here is my question, whatever choice
is 1
, 2
, or other, this loop will still run because choice can't be 1
and 2
at once. And I don't know why does this also don't work:
while choice != 1 or 2:
# some code here
I'm sorry if this is a duplicate.