I have two list that I combine into a single list. Later I want to make a copy of this list so I can do some manipulation of this second list without affecting my first list. My understanding is if you use this [:] it should unlink the list and make a second copy of the list in a independent memory location. My problem is Im not see that work for this scenario I have. I have also tried using list command as well, but the result was the same.
a = ['a','b','c']
b = ['1','2','3']
c = [a[:],b[:]] # list of list
d = c[:] # want to create copy of the list of list so I can remove last item
for item in d:
del item[-1]
# this is what I am getting returned.
In [286]: c
Out[286]:
[['a', 'b'], ['1', '2']]
In [287]: d
Out[287]:
[['a', 'b'], ['1', '2']]