0

So, I have a list variable (eg. var1) that is assigned to another list variable (eg. var2), when var2 changes var1 also changes.

Example:

movement = [3, 0]
projectile_movement = movement
projectile_movement[0] += 1
projectile_movement[1] += 1

What I am expecting to happen here, is the original movement variable should stay the same, as projectile_movement is the one being changed

However, the original movement variable is being changed along with projectile_movement

How can I stop this from happening?

martineau
  • 119,623
  • 25
  • 170
  • 301

0 Answers0