Python-Quizzes | Python List Quiz | Question 10

Question 10: Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

list1 = ['physics', 'chemistry', 1997, 2000
  
print (list1[1][-1])

chevron_right


(A) p
(B) y
(C) 7
(D) 2


Answer: (B)

Explanation: In python, we can slice a list but we can also slice an element within the list if it is a string. The declaration list[x][y] will mean that ‘x’ is the index of the element within a list and ‘y’ is the index of an entity within that string.

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.