Index error in python which is coming in list

   >>> L1=[1,2,3]
    >>> L1[3]
    Traceback (most recent call last):
    File "<pyshell#18>", line 1, in <module>
    IndexError: list index out of range

hey I am new to python and getting an error which i have never encountered

>Solution :

>>> L1=[1,2,3]
>>> L1[2]

check this out as it starts from 0 not with 1 so here:-1 will be at index0,2 at index1,and 3 at index2

Leave a Reply