Skip to content
Related Articles

Related Articles

Improve Article
Python-Quizzes | Python List Quiz | Question 8
  • Last Updated : 17 Sep, 2020

Question 8: Find the output of the following program:




list1 = [1, 2, 3, 4, 5
list2 = list1 
  
list2[0] = 0
  
print( list1)  

(A) [1, 2, 3, 4, 5, 0]
(B) [0,1, 2, 3, 4, 5]
(C) [0, 2, 3, 4, 5]
(D) [1, 2, 3, 4, 0]


Answer: (C)

Explanation: n this problem, we have provided a reference to the list1 with another name list2 but these two lists are same which have two references(list1 and list2). So any alteration with list2 will affect the original list

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :