I dont think your question is any different with this one: How to check for palindrome using Python logic
,but here is my answer: You have to reverse the string and check if the original one is the same as reversed one:
def is_palindrome(txt: str) -> bool: # Takes a string and returns a boolean
reversed_txt: str = txt[::-1]
return txt == reversed_txt
here is an example usage:
print(is_palindrome("12321")) # True
print(is_palindrome("racecar")) # True
Now you just need to find a way to remove extra charechters ("space" "," "." '!" "?" and etc)