def palindrome(string): from re import sub s = sub('[\W_]', '', string.lower()) return s == s[::-1]