When either a starting or an ending index is missing, they default to the beginning or end of the string, respectively. : slice « String « Python Tutorial






aString = 'abcd'

print aString[2:]
print aString[1:]
print aString[:-1]
print aString[:]








5.29.slice
5.29.1.Slice a string
5.29.2.How to Access Values (Characters and Substrings) in Strings
5.29.3.for any ranges [start:end], we get all characters starting at offset start up to, but not including, the character at end.
5.29.4.When either a starting or an ending index is missing, they default to the beginning or end of the string, respectively.