Advertisement
Guest User

Untitled

a guest
Jul 25th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. def isPalindrome(s):
  2.  
  3. def toChars(s):
  4. s = s.lower()
  5. ans = ''
  6. for c in s:
  7. if c in 'qwertyuiopasdfghjklzxcvbnm':
  8. ans += c
  9. return ans
  10. def isPal(s):
  11. if len(s) <= 1:
  12. return True
  13. else:
  14. return s[0] == s[-1] and isPal(s[1:-1])
  15.  
  16. return isPal(toChars(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement