Oct-31-2019, 06:37 AM
(Oct-29-2019, 08:02 PM)Mark17 Wrote:answer.lower() != ("y" or "n"):
No-one has explained why this is wrong. In Python (and other languages too, actually), all values can be tested for being
True
or False
(see the docs). Non-empty strings are treated as True
, so the expression "y" or "n"
evaluates to True
. You then compare the return value of answer.lower()
with True
and the expression answer.lower() != True
will always evaluate to True
because answer.lower()
returns a string and values of different types (string and bool here) will never be equal.