Re: Python Beginner needs help with for loop

2008-02-10 Thread John Machin
On Feb 10, 8:26 pm, Chris <[EMAIL PROTECTED]> wrote: > On Feb 10, 8:06 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > > > Hi, I'm trying to write a for loop in place of the string > > method .replace() to replace a character within a string if it's > > found. > > > So far, I've got > >

Re: Python Beginner needs help with for loop

2008-02-10 Thread Chris
On Feb 10, 8:06 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, I'm trying to write a for loop in place of the string > method .replace() to replace a character within a string if it's > found. > > So far, I've got > > s = raw_input("please enter a string: ") > c = raw_input("please enter

Re: Python Beginner needs help with for loop

2008-02-09 Thread [EMAIL PROTECTED]
I'm replacing all occurrences of the character in the string with '!', which in turn is the new string, s2. I'm also not allowed to use rfind or rindex or replace() because we are supposed to be learning about for loops. Thanks for the advices so far, I will try some more on my own. -- http://ma

Re: Python Beginner needs help with for loop

2008-02-09 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Hi, I'm trying to write a for loop in place of the string > method .replace() to replace a character within a string if it's > found. I think you mean you want to replace the last occurrence of the character in the string, but leave other occurrenc

Re: Python Beginner needs help with for loop

2008-02-09 Thread [EMAIL PROTECTED]
On Feb 10, 12:06 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, I'm trying to write a for loop in place of the string > method .replace() to replace a character within a string if it's > found. > > So far, I've got > > s = raw_input("please enter a string: ") > c = raw_input("please enter

Re: Python Beginner needs help with for loop

2008-02-09 Thread Gabriel Genellina
En Sun, 10 Feb 2008 04:06:54 -0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 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 i