IndexError
Python raises an index error when indexing into a list — my_list[index] — and the index is out of range.
Note that the text of the error message depends on the implementation. Different versions of Python and different checking tools will give slightly different messages.
sizes = ["S", "M", "L"]
chosen = sizes[3]IndexError: list index out of range
sizes = ["S", "M", "L"]
sizes[3] = "XL"IndexError: list index out of range
sizes = ["S", "M", "L"]
chosen = sizes[-4]IndexError: list index out of range

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version f5b96bc (Sun, 04 Jan 2026 17:27:49 GMT)