This questions is not a duplicate of how to copy a list, because it is essential that I keep my "list" variable the same. I cannot do
new_list = old.list.copy()
I am creating a game and the "list" is an ever-present variable. I am attempting to create actions that will essentially clone all of the contents of the EXISTING list while keeping the variable the same for future functions. Otherwise, if a function has:
list.append('Warrior')
It will only add the 'Warrior' to the old "list" and not the new_list that was created.
What I am attempting is simple. I have a list, and I want the contents to double, but in such a way that if I alter some contents of the list, I don't want it to do all of it.
list = [[x, y]]
I want
list=[[x, y], [x, y]]
But in such a way that I did
list[0][1] += 1
It would adjust the first x, and not the second (and doing it this way would alter both).
I've tried doing
list = [[x, y]]
list.append(copy.deepcopy(list))
print (list)
[[x, y], [[x, y]]]
Which doesn't work. What would you advise?