Python Beginner needs help with for loop

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Feb 10 01:47:27 EST 2008


En Sun, 10 Feb 2008 04:06:54 -0200, ty.kresher at gmail.com  
<ty.kresher at gmail.com> 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