For this test string "A man, a plan, a canal: Panama"
This code is hitting start > end, returning True, but then somehow the result is evaluated to False and I'm not sure why. Check returns True, but then the parent isPalindrome returns False
def isPalindrome(self, s: str) -> bool:
cleanString = s.lower()
cleanString = ''.join(filter(str.isalpha, cleanString))
if len(cleanString) == 1:
return True
start = 0
end = len(cleanString)-1
return check(cleanString, start, end)
def check(s: str, start: int, end: int) -> bool:
print(f'{s[start]} {start} : {s[end]} {end}')
if start > end:
return True
if s[start] != s[end]:
return False
check(s, start + 1, end - 1)
print(isPalindrome("A man, a plan, a canal: Panama"))