a = [1,[2,3]] b= [1,2,3] c=a[:] d = b[:] print(c is a , d is b )
10/15/2020 2:09:58 PM
[:] makes a copy of a list.
The new list will be equal - like a twin. But it's not the original same list. Therefore 'is' gives False.
If you write c==a, you get True.
For more details, read this:
Slick, the fun begins when you add this line to your code:
print(a is b)
HonFu i wonder why that is, they also have the same id! The madness
Slick, you will find the reason in my tutorial. 😉
Send us a message