I didn't know how (1 in [1,0] == True)
could be parsed, so I tried it in my own way.
>>> 1 in [1,0] # That's how it's supposed to be.
True
>>> 1 in [1,0] == True #Strange
False
>>> (1 in [1,0]) == True # I thought it would be parsed like this
True
>>> 1 in ([1,0] == True) # Error
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
1 in ([1,0] == True)
TypeError: argument of type 'bool' is not iterable
Python is usually chained comparisons when you look at these phrases.
(1 in [1,0] == True)
is actually
(1 in [1, 0]) and ([1, 0] == True)
It's the same thing that makes it false.
For more information
You have already answered this question [Why does Python (0 < 0 == 0) return False?]
© 2024 OneMinuteCode. All rights reserved.