arr = [1, True, 'a', 2]
print('a' in arr in arr) # False
Can you explain me why this code will output 'False'?
The question is closed.
Answer from @KlausD.: Actually it is a comparison operator chaining and will be interpreted as ('a' in arr) and (arr in arr)
.
It is
False
because'a'
isin 'arr'
but'arr'
is notin 'arr'
.Meaning
'arr'
can't be in itself.