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

0

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

+3

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

+2

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

+1

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

0

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