What is this error? How do I fix it?
It’s a problem of my program.
The IndexError is raised when attempting to retrieve an index from a sequence (e.g. list, tuple), and the index isn’t found in the sequence. The Python documentation defines when this exception is raised:
Raised when a sequence subscript is out of range.
Here’s an Python Split() example that raises the IndexError:
data = "one%two%three%four%five"
numbers = data.split('%')
The list numbers has 5 elements, and the indexing starts with 0, so, the last element will have index 4. If you try to subscript with an index higher than 4, the Python Interpreter will raise an IndexError since there is no element at such index.