I just stumbled upon the following line in Python 3.
1 in range(2) == True
I was expecting this to be True
since 1 in range(2)
is True and True == True
is True.
But this outputs False
. So it does not mean the same as (1 in range(2)) == True
. Furthermore it does not mean the same as 1 in (range(2) == True)
which raises an error.
Despite years of experience in Python, I am taken off guard. What is going on?