Ad
Code
Diff
  • import re
    
    is_palindrome = lambda s: re.sub(r'[^a-zA-Z0-9]', '', s.lower()) == re.sub(r'[^a-zA-Z0-9]', '', s.lower())[::-1]
    
    • import string
    • is_palindrome = lambda s: (x := s.replace(' ', '').lower().translate(str.maketrans('', '', string.punctuation))) == x[::-1]
    • import re
    • is_palindrome = lambda s: re.sub(r'[^a-zA-Z0-9]', '', s.lower()) == re.sub(r'[^a-zA-Z0-9]', '', s.lower())[::-1]