In article <mailman.103.1282914852.29448.python-l...@python.org>, Dave Angel <da...@ieee.org> 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 (a...@pythoncraft.com) <*> 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