Python-Quizzes | Python List Quiz | Question 3

Question 3: Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

geekCodes = [1, 2, 3, 4
  
# List will look like as [1,2,3,4,[5,6,7,8]] 
geekCodes.append([5,6,7,8]) 
  
print(geekCodes) 

chevron_right


(A) [1,2,3,4,5,6,7,8]
(B) [1,2,3,4]
(C) [1,2,3,4,[5,6,7,8]]
(D) [1,2,3,4][5,6,7,8]


Answer: (C)

Explanation: The task of the append() method is to append a passed obj into an existing list. But instead of passing a list to the append method will not merge the two lists, the entire list which is passed is added as an element of the list.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.