Question #130

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 when they are mutable. Here, a[0] and b[0] are different objects. (

Comment on Disqus:

Comment on Twitter:

Question difficulty: πŸ”΅πŸ”΅πŸ”΅πŸ”΅πŸ”΅

Similar questions: