I have a question about how changing values in copied(?) lists can affect the original one.
An Example:
a = [1, 2, [3,4]]
b = list(a)
b.append(100)
b
[1,2,[3,4],100]
a
[1,2,[3,4]]
b[2][0] = -100
b
[1,2,[-100,4],100]
a
[1,2,[-100,4]]
b[0] = 3
b
[3,2,[-100,4],100] and
a
[1,2,[-100,4]]
Why sometimes changing or adding values on list(b)
doesn't affect list(a)
and sometimes it does affect list(a)
?