replace value of a specific position

Tom llafba at
Thu Jul 10 19:36:16 CEST 2003


I want to replace a specific part of a string. I tried replace but this 
doesn't work the way I want it, because it checks and replaces all 
values and not the position (index).

t = '010010101001001110100101010111'
t = t.replace(t[5], '2')

This is just a bad example of what I tried. It produces this output:


But I wanted:


I couldn't find anything in the python library. I probably looked at the 
wrong place! :-) That's why I would appreciate your help.

Thank you very much, Tom

More information about the Python-list mailing list