-1
   >>> 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

1 Answers1

0
>>> 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

Barmar
  • 741,623
  • 53
  • 500
  • 612