Dear All - sorry to bother you. I just tried to run this program:


def isPalindrome(s):
if len(s) <= 1: return True 
else: return s[0] == s[-1] and isPalindrome (s[1:-1])
isPalindrome('aba')


However when I run it in terminal it doesn't give me any answer - True or 
False. (I want the program to tell me whether the input string is True or 
False). In order to get an answer, I assume I would need to tell the program to 
print something. However I'm not sure where in the program I would do this. I 
tried this:

def isPalindrome(s):
if len(s) <= 1: return True and print "True"
else: return s[0] == s[-1] and isPalindrome (s[1:-1])
isPalindrome('aba')

However, this does not work - I get another error message. 

Could somebody advise what I'm doing wrong here? Thank you.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to