Advertisement
Guest User

Untitled

a guest
Apr 9th, 2013
185
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None
  1. Python 2.7.3 (default, Apr 27 2012, 21:06:39)
  2. [GCC 4.7.0] on linux2
  3. Type "help", "copyright", "credits" or "license" for more information.
  4.  
  5. >>> import re
  6.  
  7. >>> def is_palindrome(i):
  8. ... i=''.join(re.findall('[a-z0-9]+',i.lower()))
  9. ... return i==i[::-1]
  10. ...
  11.  
  12. >>> print is_palindrome('Eva, can I stab bats in a cave?')
  13. True
  14.  
  15. >>> print is_palindrome("Madam, I'm Adam Corolla.")
  16. False
  17.  
  18. >>> print is_palindrome('A_man,_a_plan, a_caremer, a canal:_Panama!')
  19. True
Advertisement
RAW Paste Data Copied
Advertisement