I have this code:
>>> char = 'A'
>>> 'A' == char
True
>>> ('A' or 'B') == char
True
Why does this not equal True?
>>> ('B' or 'A') == char
False
Your expressions are not doing what you expect.
'A' or 'B'
This actually evaluates to 'A', try it out in the interpreter!
When you say
('A' or 'B') == char
The interpreter is actually doing these steps:
('A' or 'B') == char
('A') == char
True
But when you do
('B' or 'A') == char
The interpreter does this:
('B' or 'A') == char
('B') == char
False
What you probably wanted was:
'A' == char or 'B' == char
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With