New course! Every coder should learn Generative AI!
Try a free lesson+ 20
Why this is False⁉️🤔
lst = ["a", True] print("a" in lst in lst)
6 Answers
+ 15
It seems to work the same as :
print('a' in lst and lst in lst) ⁉️
+ 4
Janusz Bujak 🇵🇱 this is what youre after
print(("a" in lst)in lst)
“(“a” in lst)” evaluates True FIRST then tests for “True in lst” which returns True.
+ 2
Use : print("a" in lst)
+ 1
Not sure if this help to explain but ..
lst = [1, True, 'a']
lst2 = [[1, True, 'a'], [1, 2], [3, 4], [5, 6]]
print('a' in lst in lst2) ### returns True
+ 1
That's exactly how it works, Janusz Bujak 🇵🇱.
0
because,you used in print"a" which is an element. But you should use in print(1st,"in 1st in list")