Open In App
Related Articles

Python-Quizzes | Python List Quiz | Question 21

Improve Article
Improve
Save Article
Save
Like Article
Like

Find the output of the following program: 

Python3




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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 17 Sep, 2020
Like Article
Save Article
Similar Reads