Open In App

Python-Quizzes | Python List Quiz | Question 21

Find the output of the following program: 




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

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

Article Tags :