Open In App
Related Articles

Python-Quizzes | Python List Quiz | Question 14

Improve Article
Save Article
Like Article

Find the output of the following program: 


list = ['a', 'b', 'c', 'd', 'e']
print(list[10:] )


[\’a\’, \’b\’, \’c\’, \’d\’, \’e\’]


[ \’c\’, \’d\’, \’e\’]


[ ]


[\’a\’, \’b\’]

Answer: (C)


As one would expect, attempting to access a member of a list using an index that exceeds the number of members (e.g., attempting to access list[10] in the list above) results in an IndexError. However, attempting to access a slice of a list at a starting index that exceeds the number of members in the list will not result in an IndexError and will simply return an empty list.

Quiz of this Question
Please comment below if you find anything wrong in the above post

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