Slice indexing is inclusive in front, and exclusive in back. For example,
h = "Hello, World!"
print(h[3:6])
# 'lo,'
includes indices 3
, 4
, and 5
, but not 6
.
When you do [13:-1]
, you're grabbing everything from index 13
to index -1
, but not index -1
itself. To get "everything after 13", you can just leave the second field in the slice blank:
print(h[8:])
# 'orld!'
You can do the same to get "every character before index 8
":
print(h[:8])
# 'Hello, W'
and leaving both fields blank actually just produces a copy of the thing you're trying to slice:
print(h[:])
# 'Hello, World!'