In Python, what happens if we try to access an invalid index of a string?
If we try to access an index of a string that’s not a valid index, then the
IndexError will be thrown. This will also apply when using negative indices, as it will try to access an index starting from the final index moving left.
string = "Hello" # These will both give an IndexError print(string) print(string[-6])