IndexError in Python — What It Means and How to Fix It

What Python's IndexError exception means and how to resolve it.

Published October 27, 2026

IndexError is raised when a sequence (like a list) is accessed with an index that's out of range.

Key points

  • Catch it specifically with "except IndexError:" when you want to handle this exact case rather than a bare except

Example

[1, 2, 3][10]  # IndexError: list index out of range
More Python articles