Reputation: 39
a = [1,2,3]
b = [a.copy(),a]
c = b.copy()
print(b[0] is c[0])
>>> True
print(c[1] is a)
>>> True
Hi, I've been trying out shallow copying and I don't really understand why b[0] is c[0]. If c is a shallow copy of b, shouldn't it be independent of it? I've tried visualising with pythontutor but I still don't get it.
Thanks in advance
Upvotes: 1
Views: 21