>>>> idx = 1
>>>> s1 = "pxthon"
>>>> s1[idx] = 'y'
> Traceback (most recent call last):
> File "
> TypeError: object does not support item assignment
But you can always go for a way out which is not pretty and can lead to some problems if you are not careful, but works :
s1 = s1[0:idx] + 'y' + s1[idx+1:]
No comments:
Post a Comment