On May 3, 9:44 am, Johny <[EMAIL PROTECTED]> wrote:
> On May 3, 4:37 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > On May 3, 9:27 am, Johny <[EMAIL PROTECTED]> wrote:
>
> > > Let's suppose
> > > s='12345 4343 454'
> > > How can I replace the last '4' character?
> > > I tried
> > > string.replace(s,s[len(s)-1],'r')
> > > where 'r' should replace  the last '4'.
> > > But it doesn't work.
> > > Can anyone explain why?
>
> > > Thanks
> > > L.
>
> > I think the reason it's not working is because you're doing it kind of
> > backwards. For one thing, the "string" module is deprecated. I would
> > do it like this:
>
> > s = s.replace(s[len(s)-1], 'r')
>
> > Although that is kind of hard to read. But it works.
>
> > Mike
>
> Mike it does NOT work for me.>>> s.replace(s[len(s)-1], 'r')
>
> '123r5 r3r3 r5r'
>
> I need only the last characte


Yeah...I'm an idiot. Sorry about that. Listen to the other users!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to