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.
--
http://mail.python.org/mailman/listinfo/python-list