If I execute this code:
a = [1,2,3]
b = a
b.remove(2)
print(a,b)
What I expect to see is:
[1,2,3] [1,3]
But this is what I really get:
[1,3] [1,3]
Why calling b.remove(2)
also affects a
?
What if I want to change b
,while keeping a copy of the original content in a
?