This is normal. When you assign an object to a variable, python will not copy this object to your variable. It will simply assign the link of the source object to your new object.
In [1]: a = [1,2] In [2]: b = a In [3]: a.remove(1) In [4]: b Out[4]: [2]
Here b will only contain a link to the original list a. If you want to override this behavior, you can use the copy module.
In [7]: import copy In [8]: a = [1,2] In [9]: b = copy.deepcopy(a) In [10]: a.remove(1) In [11]: b Out[11]: [1, 2]
deepcopy duplicates everything, including individual elements.
source share