Python Beginner needs help with for loop

Gabriel Genellina gagsl-py2 at
Sun Feb 10 07:47:27 CET 2008

En Sun, 10 Feb 2008 04:06:54 -0200, ty.kresher at  
<ty.kresher at> escribi�:

> I need to replace s2 = s.replace(c,"!") with a for loop function
> somehow.
> I don't really see how a for loop would iterate through the string and
> replace the character, and would like to see an example if possible.

Try starting with an empty string, and building the output one character  
at a time (s = s + x); when you are at the position to be replaced, use  
the replacement character instead.

Gabriel Genellina

More information about the Python-list mailing list