i get different answers based on run platform

MRAB python at mrabarnett.plus.com
Thu Jul 7 20:59:05 CEST 2011


On 07/07/2011 19:37, John Gordon wrote:
> In<842fce9d-1b3f-434a-b748-a6dc4828c385 at h12g2000pro.googlegroups.com>  linda<postslot at gmail.com>  writes:
>
>> I have this simple palindrome program that yields different results
>> depending on whether I run it from Windows or from IDLE.  The answer
>> is correct off IDLE, but why is this the case?  Here's the code:
>
> Your code contains debugging statements that print the value of the normal
> string and the reversed string.  What do those statements print when you
> run your program under Windows?  That should go a long way towards telling
> you what the problem is.
>
> (Perhaps Windows leaves a linefeed character hanging at the end of the
> input line, which upsets the palindromic balance?)
>
> By the way, I could not make your program work as you provided it; I had
> to replace input() with raw_input().  Does it really work for you this way?
>
It's Python 3.

Python 2's raw_input() has been renamed input() in Python 3 and Python
2's input() was never in Python 3 because it uses eval on the string,
which usually undesirable.



More information about the Python-list mailing list