What is the difference between shallow copy and deep copy?
Model answer
A shallow copy (copy.copy, list.copy, slicing) creates a new container but the nested objects are shared. A deep copy (copy.deepcopy) copies nested objects too. Changing a nested list in a shallow copy also changes the original.
Learn this topic
Variables, Numbers, Text and input() in Python in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.