str.lower() and re.sub() to convert to lowercase and remove non-alphanumeric characters from the given string.from re import sub def palindrome(s): s = sub('[\W_]', '', s.lower()) return s == s[::-1]
palindrome('taco cat') # TrueSubscribe to get resources directly to your inbox. You won't receive any spam! ✌️