D
Danny Castonguay
Simple question but I can't find the answer. Using an example:
listA = [1 ,2]
listB = listA
listB.append(3)
#listA now is [1,2,3]
I want to avoid listA's value to change. Clearly, "listB = listA"
creates the problem. listB and listA become two pointers to the same
object. How then, do I duplicate the two objects; ie make a copy of the
object that listA is pointing to and have listB point to that object.
I'm new to python and I love it.
Thank you,
listA = [1 ,2]
listB = listA
listB.append(3)
#listA now is [1,2,3]
I want to avoid listA's value to change. Clearly, "listB = listA"
creates the problem. listB and listA become two pointers to the same
object. How then, do I duplicate the two objects; ie make a copy of the
object that listA is pointing to and have listB point to that object.
I'm new to python and I love it.
Thank you,