0

Why does the following indexing throws error

string = "ABC"
string[4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range

but not when

string[4:]
'' 
Coddy
  • 549
  • 4
  • 18
  • https://stackoverflow.com/q/9490058/1424875 seems to cover the same question. Can you take a look and see if it addresses what you wanted to know, and if not, [edit] your post to clarify? – nanofarad Oct 13 '22 at 03:54

0 Answers0