Why does str[64:] work while str[64] doesn't?

Viewed 57

Say you have a string named s:

s = "000000000000000000000000000000000000000000000000000000000000000"
len(s)
#63

When you run s[64:], the Python compiler returns ''.
However, when you run s[64] the code raises the following error:

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

Why does this happen?
Thanks in advance.

0 Answers
Related