79261951

Date: 2024-12-08 06:33:36
Score: 0.5
Natty:
Report link

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)

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: sina kasesaz