What is the output of following code in Python?

>>> thelist=[‘a’,’b’]
>>> print thelist[3:]

Ans: The output of this code is following:

Even though the list has only 2 elements, the call to thelist with index 3 does not give any index error.

Leave a Reply

Your email address will not be published. Required fields are marked *