230k views
4 votes
Python string indexerror: list index out of range

1 Answer

4 votes
A string is actually an array of characters. Because it's an array, the characters can be addressed by index. Arrays in Python are zero indexed (the first element is index 0, the second is index 1, etc.). One thing about zero based indexing that bites people is that the last indice is len() - 1. Otherwise you get a "List Index Out of Range" error.
User Steve Czetty
by
5.8k points