Indexing And Slicing Strings

Strings use indexes and slices just like lists .

>>> spam = 'Hello, world!'
>>> spam[0]
'H'
>>> spam[-1]
'!'
>>> spam[0:5]
'Hello'
>>> spam[:5]
'Hello'
>>> spam[7:]
'world!'