indexerror list index out of range python web scraping code example
Example 1: find index of elem list python
# Find index position of first occurrence of 'Ok' in the list
indexPos = listOfElems.index('Ok')
print('First index of element "Ok" in the list : ', indexPos)
Example 2: python list index out of range
#this will result in an IndexError
arr = ['item',1,None,'hi']
error = arr[10]
Example 3: remove iwth index list python
>>> a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> del a[-1]
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8]