I have this (simplified):
foo = input("Test")
if foo is "a" or "b":
print("Test")
This returns Test for everything that the user inputs, while those work and only return when a
or b
is given.
foo = input("Test")
if foo is "a" or foo is "b":
print("Test")
-
foo = input("Test")
if foo in ("a" or "b"):
print("Test")
Why does the first one not work?
I can only guess that the first one actually checks if foo == "a"
, but not if foo == "b"
, and that the or "b"
part always returns True
- but why?