Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python-Quizzes | Python List Quiz | Question 8

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Find the output of the following program: 

Python3




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:

In 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
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 17 Sep, 2020
Like Article
Save Article
Similar Reads