xxxxxxxxxx
list1 = [['a', 8, 7], [6, 5, 4], [3, 2, 1]]
list2 = list1
list2[0][0] = 9
print('Old List:', list1)
print('ID of Old List:', id(list1))
print('New List:', list2)
print('ID of New List:', id(list2))
xxxxxxxxxx
import copy
# Shallow Copy
# doesn't create a copy of nested objects
# instead it just copies the reference of nested objects.
new_obj1 = copy.copy(old_obj)
# Deep Copy
# Creates copy of nested objects recursively
new_obj2 = copy.deepcopy(old_obj) # Deep Copy