The reason why the execution result of the expression "in [1,0] == True" is false: [==] in the expression is equivalent to and, that is, [(1 in [1, 0]) and ([1, 0] == True)].
Why is the execution result of in [1,0] == True false?
Running in python found:
>>> 1 in [1,0] == True # This is strangeFalse >>> False
Python actually applies comparison operator chaining here. The expression is translated to
(1 in [1, 0]) and ([1, 0] == True)
which is obviously False.
This also works for expressions like
a < b < c
converts to
(a < b) and (b < c)
The above is the detailed content of Why the expression 'in [1,0] == True' evaluates to false. For more information, please follow other related articles on the PHP Chinese website!