Question #132

What is the output of the code snippet below?
import copy
a = [1, 2]
b = copy.deepcopy(a)
print(a[0] is b[0])

When copy.deepcopy() is used, the copy of the object has a new memory address and its elements have new memory addresses too. However, the elements of a here are not mutable and as such copy.deepcopy() returns a shallow copy (behaves like copy.copy() ). (towardsdatascience.com/assignment-shallow-or-deep-a-story...)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵


Similar questions: