I have a list that I am trying to fill with numbers from a different List. However, when I change the number in the list I copied from, it changes them in the other list. Is there any way to stop this from happening?
I have a list that I am trying to fill with numbers from a
Share
You need to copy the values in your list into a new list:
That will copy all of the values in
list1intolist2. Then you can make changes tolist2without modifyinglist1and vice versa.Just to clarify:
That will not do a deep copy. However, this is not an issue of deep/shallow copying. The issue here is that the OP was passing his list into another method and then was surprised to learn that his list had had numbers added/removed.