Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 8 Online
OpenStudy (anonymous):

Why doesn't this code returns False when it's not a palindrome?

OpenStudy (anonymous):

def toChars(s): import string s = string.lower(s) ans = '' for c in s: if c in string.lowercase: ans = ans + c return ans def isPal(s): if len(s) <= 1: return True else: return s[0] == s[-1] and isPal(s[1:-1]) def isPalindrome(s): """Returns True if s is a palindrome and False otherwise""" return isPal(toChars(s))

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!