Ben Wise Ben Wise - 7 months ago 16
Python Question

Python string slice indices - slice to end of string

With string indices, is there a way to slice to end of string without using len()?
Negative indices start from the end, but [-1] omits the final character.

word = "Help"
word[1:-1] # But I want to grab up to end of string!
word[1:len(word)] # Works but is there anything better?

Answer

You can instead try using:

word[1:]