+ 2
[SOLVED] Please explain this statement
print(False== False in [False]) # why output is True ?
4 Answers
+ 5
Because of Python's comparison chaining feature.
False== False in [False]
is treated as
(False == False) and (False in [False]) which returns True.
+ 2
Erik Are you familiar with 1 < x < 10?
It's the same thing.
+ 1
Yeah the 1 < x < 10 form is familiar, but it somehow seemed different in my head with equality (rather than inequality) comparisons.
I think maybe it was my confusion with this similar-looking (but quite different) idiom:
x = y == 10
...where you do an assignment of a boolean value (to x) based on a comparison (of y).