This is due to the fact that both operators are comparison operators, so it is being interpreted as operator chaining:
https://docs.python.org/3.6/reference/expressions.html#comparisons
Comparisons can be chained arbitrarily, e.g., x < y <= z
is equivalent
to x < y and y <= z
, except that y
is evaluated only once (but in both
cases z
is not evaluated at all when x < y
is found to be false).
So it is equivalent to:
>>> (1 in range(2)) and (range(2) == True)
False