Dear all,
Sorry to bother you with a beginner's problem again...
I have tried to write a program that can check if a string is a palindrome. My
code is as follows:
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 try to run it in terminal I get the following error message:
Traceback (most recent call last):
File "recursion.py", line 5, in <module>
isPalindrome('aba')
File "recursion.py", line 3, in isPalindrome
else: return s(0) == s(-1) and isPalindrome (s[1:-1])
TypeError: 'str' object is not callable
I don't see why this wouldn't work...
Many thanks in advance.
Kind regards,
Victoria _______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor