I am trying to update a list of Recorded Coordinates for a simple snake game. However, when I try to save the coordinates in the list, they all update to the most recent values.
I have tried setting the coordinates to a more global scale instead of inside a class file and making copies of the data I need, however none of these worked. A simple example of this is here:
my_list = []
run = True
var1 = [5, 50]
i = 0
while run and i <= 10:
i += 1
my_list.append(var1)
var1[0] += 1
var1[1] -= 1
print(my_list)
I am running python 3.11.0.