Occurs when accessing a character outside the string length.
text = "hi"
print(text)
char = text[5]
print(char)IndexError: string index out of range
text = "hi"
print(text)
if len(text) > 5:
char = text[5]
print(char)Ended up accessing an index that didn’t exist.
- Related case: https://pyai.io/en/python/basic/strings/