0
usin "in" list
ages = [11,23,44,46,67] print(11 in ages) = true print(2 and 11 in ages) = true print(11 and 2 in ages) = false print((2 and 11) in ages) = true print((11 and 2) in ages) = false can anyone please explain reason for above output.
2 Answers
+ 5
2 is true
11 in ages is true
11 is true
2 in ages is false
it is different to
2 in ages and 11 in ages
+ 4
2 and 11 in ages doesn't mean what you think it means.
It checks if 2 is true (which it is), and then it checks if 11 is in ages.
So you need to write:
2 in ages and 11 in ages