Back to Python Errors
Python Exception

IndexError

List index out of range

What does this error mean?

Occurs when trying to access an index that doesn't exist in a list or tuple.

How to fix IndexError?

Check list length before accessing. Use len() to verify valid index range.

Example
lst = [1, 2]; print(lst[5]) # IndexError: list index out of range