On 23 August 2012 15:17, Victoria Homsy <victoriaho...@yahoo.com> wrote:
> > def isPalindrome(s): > if len(s) <= 1: return True > else: return s(0) == s(-1) and isPalindrome (s[1:-1]) > > I don't see why this wouldn't work... > > Many thanks in advance. > > Kind regards, > > Victoria > Parentheses are used for function arguments in Python, whereas square brackets are used for slices - so the first character of s is not s(0) but s[0]. When you say s(0) and s(-1), Python thinks you're calling s as a function with 0 or -1 as the argument - hence, "str object is not callable".
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor