Ad

took only the library needed.

Code
Diff
  • from re import sub
    
    is_palindrome = lambda s: sub(r'[^a-zA-Z0-9]', '', s.lower()) == sub(r'[^a-zA-Z0-9]', '', s.lower())[::-1]
    
    • import re
    • from re import sub
    • is_palindrome = lambda s: re.sub(r'[^a-zA-Z0-9]', '', s.lower()) == re.sub(r'[^a-zA-Z0-9]', '', s.lower())[::-1]
    • is_palindrome = lambda s: sub(r'[^a-zA-Z0-9]', '', s.lower()) == sub(r'[^a-zA-Z0-9]', '', s.lower())[::-1]