Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9052

Re: i get different answers based on run platform

Date 2011-07-07 19:54 +0100
From MRAB <python@mrabarnett.plus.com>
Subject Re: i get different answers based on run platform
References <842fce9d-1b3f-434a-b748-a6dc4828c385@h12g2000pro.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.760.1310064891.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 07/07/2011 19:18, linda wrote:
> 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:
>
> def reverse(text):
>      return text[::-1]
> def is_palindrome(text):
>      return text==reverse(text)
> while True:
>      something=input('enter text:')
>      print(something)
>      print(something[::-1])
>      if (is_palindrome(something)):
>          print("yes, it is a palindrome")
>          break
>      else:
>          print("no, it is not a palindrome")
>          continue
> print ('done')
>
> Thanks for your help.
>
Try printing ascii(something) too.

There's a known bug in Python 3.2 where it leaves a training '\r', if
that's what you're using (http://bugs.python.org/issue12435), fixed in
Python 3.2.1.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

i get different answers based on run platform linda <postslot@gmail.com> - 2011-07-07 11:18 -0700
  Re: i get different answers based on run platform John Gordon <gordon@panix.com> - 2011-07-07 18:37 +0000
    Re: i get different answers based on run platform Ethan Furman <ethan@stoneleaf.us> - 2011-07-07 12:11 -0700
    Re: i get different answers based on run platform MRAB <python@mrabarnett.plus.com> - 2011-07-07 19:59 +0100
      Re: i get different answers based on run platform linda <postslot@gmail.com> - 2011-07-07 14:09 -0700
        Re: i get different answers based on run platform Ethan Furman <ethan@stoneleaf.us> - 2011-07-07 14:42 -0700
          Re: i get different answers based on run platform linda <postslot@gmail.com> - 2011-07-07 14:37 -0700
  Re: i get different answers based on run platform Ethan Furman <ethan@stoneleaf.us> - 2011-07-07 11:58 -0700
  Re: i get different answers based on run platform MRAB <python@mrabarnett.plus.com> - 2011-07-07 19:54 +0100

csiph-web