Question #126

What is the output of the code snippet below?
a = [1, 2, 3]
b = a.copy()
a = a.append(5)

When a is copied to b with copy() , Python create a new object as a copy from the list assigned to a . Any changes done to the list assigned to a is not reflected when accessing b as a different list is assigned to it. (

Comment on Disqus:

Comment on Twitter:

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

Similar questions: