I want to create a code that will return \"true\" (if I type in a palindrome regardless of case or if there are special characters in it), and \"false\" otherwise. The code I ha
If you just want to exclude punctuation and spaces you can use str.translate:
from string import punctuation
d = {k: None for k in punctuation}
d[" "] = None
def is_palindrome(my_str):
trans = str.maketrans(d)
my_str = my_str.translate(trans).casefold()
return my_str == my_str[::-1]