In article <[email protected]>,
Dave Angel  <[email protected]> wrote:
>
>def is_palindrom(s):
>    s = s.lower()
>    return s == s[::-1]

To deal with "real" palindromes such as, "Madam, I'm Adam," you should
probably strip all spaces and punctuation:

# untested
pat = re.compile(r'[a-z]')
def is_palindrome(s):
    letters = pat.findall(s.lower())
    return letters == reversed(letters)
-- 
Aahz ([email protected])           <*>         http://www.pythoncraft.com/

[on old computer technologies and programmers]  "Fancy tail fins on a
brand new '59 Cadillac didn't mean throwing out a whole generation of
mechanics who started with model As."  --Andrew Dalke
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to