Programming Languages
Python
Subjective
Sep 30, 2025
What is the difference between shallow copy and deep copy? Show with code.
Detailed Explanation
import copy\noriginal = [[1, 2], [3, 4]]\nshallow = copy.copy(original) # or original.copy()\ndeep = copy.deepcopy(original)\n\noriginal[0][0] = 99\n# shallow[0][0] is also 99, deep[0][0] remains 1
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts