python: changes to my copy variable affect the original variable [duplicate]

That is because in python setting a variable actually sets a reference to the variable. Almost every person learning python encounters this at some point. The solution is simply to copy the list:

copy_list = org_list[:] 

Leave a Comment