Shallow Copy
say it: “SHAL-oh KOP-ee” /ˈʃæloʊ ˈkɑpi/
A new collection that still shares the items inside it with the original.
What is a shallow copy?
A shallow copy is a new list (or dictionary) that still shares the items inside it with the original. Changing a list inside it changes both.
teams = [["Ana"], ["Ben"]]
copy = teams.copy()
copy[0].append("Cai")
print(teams) # [['Ana', 'Cai'], ['Ben']]: changed too!
Level: Journeyman · More Python terms at this level
Updated