Why output of this code is 'false'? | SoloLearn: Learn to code for FREE!


Why output of this code is 'false'?

x = [ 1,3,5 ] print (x in x)

2/22/2020 4:29:34 PM

Peter Parker

5 Answers

New Answer


Because the list is not a member of itself, only elements inside are members of the list.


Alexandr Next question will be what is [...], because you just created a self-referencing list 😉 WhyFry Good example...


[not answer] [off-topic] Hari Shankar As continuation of Alexandr's example check this out. https://code.sololearn.com/cC6sIz1KO4ax/?ref=app


x = [1, 3, 5] x.append(x) print(x in x) Output of this is true