> 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)
Using python 2.5 the above solution always returned False for me until the reversed( letters ) iterator was explicitly coerced into a list .... return letters == list( reversed( letters ) ) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list