Python-Quizzes | Python List Quiz | Question 23

Last Updated :
Discuss
Comments

Find the output of the following program: 

Python
a = [1, 2, 3, 4] 
b = a 
c = a.copy() 
d = a
a[0] = [5] 
print(a, b, c, d) 

[5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]

[[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]

[5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]

[[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [[5], 2, 3, 4]

Share your thoughts in the comments