I'm using python 3.4.1.
For a single list a=[1,2]
, if I make a copy of it, b = a.copy()
when I change items in b
, it won't change items in a
.
However, when I define a list of lists (actually a matrix) a = [[1,2],[3,4]]
, when I assign b = a.copy()
. What I do to list b
actually affects a
.
I checked their addresses, they are different.
Can anyone tell me why?
ps: What I did is b[0][0] = x
, and the item in a was also changed.