You can download this code by clicking the button below.
This code is now available for download.
Determines if a string is a palindrome, i.e., a string that reads the same forwards and backwards.
Technology Stack : str, re, math
Code Type : Function
Code Difficulty : Intermediate
import math
import re
def is_palindrome(s):
if not isinstance(s, str):
return False
s = re.sub(r'\W+', '', s).lower()
return s == s[::-1]