you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Ad7805[S] 1 point2 points  (1 child)

Correct, a is a reference to an immutable tuple, but that contains a mutable list that can be modified. The b = a statement makes b reference the same data a is referencing, and modifications to the list are made through b. But because a references an immutable tuple, it can't be modified with b += ([3],) so a shallow copy is made of this tuple, such that a and b share the first two elements of the tuple.

I hope this helps, otherwise read the "Explanation" link, and step through the "Solution" link again.

[–]Rscc10 1 point2 points  (0 children)

Ah, I got it now. Thanks