List index out of range

broken image
broken image
broken image

It means that you are referring to n-th element of the python list, while the length of the list is smaller than n. Index Error: List index out of range means you are trying to get an item in a list that doesn’t exist.

broken image

The way Python indexing works is that it starts at 0, so the first number of your list would be. To solve this error, you should make sure that you’re not trying to access a non-existent item in a list. If you try to access the empty or None element by pointing available index of the list, then you will get the ' List index out of range ' error. So if there are n elements in a python list, the last element is n-1. So the first element is 0, second is 1, so on. This error basically means you are trying to access a value at a List index which is out of bounds i.e greater than the last index of the list or less than the least index in the list.

broken image