Got code that looks like this, and it's not working properly?
if x == "foo" or "bar" or "baz":
Python is interpreting this as though it was this:
if (x == "foo") or ("bar") or ("baz"):
If the first expression (x == "foo"
) isn't true, the second ("bar"
) will be, so this compound conditional always passes.
Try this instead:
if x == "foo" or x == "bar" or x == "baz":
or, even better:
if x in ("foo", "bar", "baz"):