Python-Quizzes | Python List Quiz | Question 21

Question 21: Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

L1 = []
L1.append([1, [2, 3], 4]) 
L1.extend([7, 8, 9]) 
print(L1[0][1][1] + L1[2]) 

chevron_right


(A) Type Error
(B) 12
(C) 11
(D) 38


Answer: (C)

Explanation: In the print(), indexing is used. L1[0] denotes [1, [2, 3], 4], L1[0][1] denotes [2, 3], L1[0][1][1] = 3 and L1[2] = 8. Thus, the two integers are added, 3 + 8 = 11 and output comes as 11.

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.