You can convert the string to an object that does support in-place changes:
S = 'testmy' L = list(S) print( L )
The built-in list function builds a new list out of the items in any sequence.
Here, it explodes the characters of a string into a list.
You edit the list and then convert back to string.
S = 'testmy' L = list(S) # from w ww . j a va 2 s.c o m L[3] = 'x' # Works for lists, not strings L[4] = 'x' print( L ) S = ''.join(L) print( S )
The join method is from string not list.
It uses the empty string delimiter to convert from a list back to a string