IndexError: List index out of range. if not 0 <= index <= len(self) - 1: # test if index is valid raise IndexError("List index out of range.") ...