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 a9143b0 (Sun, 14 Dec 2025 12:09:46 GMT)