Problem with what raw_input() returns

Terry Reedy tjreedy at udel.edu
Mon Jan 12 22:48:45 EST 2004


"sebb" <sebb at linuxcult.com> wrote in message
news:56f42e53.0401121746.39b9e4db at posting.google.com...
> # -*- coding: cp1252 -*-
> one = "éé"
> two = one.replace("é","a")
>
> print two # it prints aa as I expected
>
> # -*- coding: cp1252 -*-
> one = raw_input() # When I run the script, I type éé
> two = one.replace("é","a")
>
> print two # it still prints éé and I want it to print aa
>
> Can someone help me with that problem?
> Thanks

Learn some basic debugging with print, repr, and ==; or if you know it, use
it; or if you did, share results with us ;-)

In particular, use different name for second input, print both before
replace attempt, and use explicit equality tests.
oneb = raw_input()
print repr(one), repr(oneb), one == oneb

Then draw conclusions and possibly make further test according to results.

Terry J. Reedy





More information about the Python-list mailing list