SHARE
TWEET

Untitled

a guest Apr 9th, 2013 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top