When True is not element of the list, why it returns True?
print(True in [1,2,3])
True
is implictly converted to a number, 1
. (False
would be converted to 0
) The in
operator checks if any element is equal to the left operand, and True
is equal to the first element, 1
.
>>> True == 1
True