Replace single character at given position
Roberto.Bonvallet at cern.ch
Wed Sep 20 16:12:40 CEST 2006
bearophileHUGS at lycos.com wrote:
> Martin Kulas:
>> Are there better (faster) ways to achieve my goal?
>> I have looked through the methods of type ``string''
>> but I have not found any appropriate method or function.
> A second way is to use a list of strings with len=1. Like this:
>>>> idx = 1
>>>> s1 = "pxthon"
>>>> l1 = list(s1)
>>>> l1[idx] = 'y'
> ... more processing on the elements of l1, then at the end:
There is a MutableString class that would be a better approach:
Anyway, I bet that what Martin wants to do can be done by using only string
More information about the Python-list