Ben Wise Ben Wise - 2 years ago 92
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 Source

You can instead try using:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download