trouble with replace

f pemberton fpemberton133 at yahoo.com
Sat Aug 12 13:31:34 EDT 2006


Marc 'BlackJack' Rintsch wrote:
> In <1155401390.926925.252000 at m79g2000cwm.googlegroups.com>, f pemberton
> wrote:
>
> > I've tried using replace but its not working for me.
> > xdata.replace('abcdef', 'highway')
> > xdata.replace('defgef', 'news')
> > xdata.replace('effwer', 'monitor')
>
> `replace()` does not work in place.  You have to bind the result to a name
> like::
>
>   xdata = xdata.replace('abcdef', 'highway')
>
> Ciao,
> 	Marc 'BlackJack' Rintsch

lol, you probably will not believe me but I actually knew that already.
 I just forgot to add that part in my original post. When I try and
replace what happens is the first replace works fine but when I try and
do a second replace on a different part of the same string, the program
will print the string a second time(which I do not want). How can you
do 2 or more replaces in one line of code?




More information about the Python-list mailing list