I have a list that I add items to as the program runs and I have created a copy of this list so I can change/modify/examine the copy WITHOUT changing the original.
This is what I’ve got so far:
import copy
originallist.append(stuff)
combined=''.join(originallist)
copyoriginal=copy.deepcopy(originallist)
##this didnt work as copyoriginal stayed empty [] while originallist would change.
#i also tried
copyoriginal=list(originallist)
#AND
copyoriginal=originallist[:]
#and with both cases copyoriginal remained at [] while originallist would change!!
Why does it not change?
If you want to “keep up with changes” to another list, you may want to consider using a simple reference instead of a copy:
You can always make a copy later when you decide you want to stop tracking changes: