from copy import deepcopy
if __name__ == '__main__':
x = [1, 2]
y = [x, x]
# create a copy of list y
clone = deepcopy(y)
# remove the last item from the original list
x.pop()
# cloned list remains unchanged
print(clone) # [[1, 2], [1, 2]]
import copy
list1 = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]
list2 = copy.deepcopy(list1)
print("Old list:", list1)
print("New list:", list2)
import copy
list_to_copy = ['a', 2, 'foo']
new_deepcopy = copy.deepcopy(list_to_copy)