>>> 'hello'
'hello'
>>> len('hello')
5
>>> s = 'hello'
>>> s[0]
'h'
>>> s[1]
'e'
>>> s[4]
'o'
>>> s[5]
Traceback (most recent call last):
File "", line 1, in
IndexError: string index out of range
>>> t = 'Hello CSCI 150!'
>>> t[5]
' '
>>> s[0] = 'j'
Traceback (most recent call last):
File "", line 1, in
TypeError: 'str' object does not support item assignment
>>> s[0] + 'i'
'hi'
>>> s[-1]
'o'
>>> s[-2]
'l'
>>> s[-3]
'l'
>>> s[1:3]
'el'
>>> s[2:4]
'll'
>>> s[2:5]
'llo'
>>> s[0:2] + s[2:5]
'hello'
>>> s[2:]
'llo'
>>> s[:3]
'hel'
>>> s[:]
'hello'
>>> 'j' + s[1:]
'jello'
>>> s
'hello'