a = ‘abc’
a[1] = ‘x’
print a
Have Error
Traceback (most recent call last):
File “<pyshell#1>”, line 1, in <module>
a[1] = ‘x’
TypeError: ’str’ object does not support item assignment
Change to
a = ‘abc’
a = a[:1] + ‘x’ + a[2:]
print a
Let’s Rock!!!
a = ‘abc’
a[1] = ‘x’
print a
Have Error
Traceback (most recent call last):
File “<pyshell#1>”, line 1, in <module>
a[1] = ‘x’
TypeError: ’str’ object does not support item assignment
Change to
a = ‘abc’
a = a[:1] + ‘x’ + a[2:]
print a