i get different answers based on run platform
Ethan Furman
ethan at stoneleaf.us
Thu Jul 7 14:58:22 EDT 2011
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:')
try changing this to:
something = input('enter text:').rstrip('\n')
> 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')
More information about the Python-list
mailing list