diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py new file mode 100644 index 000000000000..9ebfc44f1c3e --- /dev/null +++ b/strings/is_palindrome.py @@ -0,0 +1,24 @@ +def is_palindrome(input_string: str) -> bool: + """ + Check if a given string is a palindrome. + + A palindrome is a string that reads the same forward and backward. + + Args: + input_string (str): The string to check. + + Returns: + bool: True if the string is a palindrome, False otherwise. + + Examples: + >>> is_palindrome("madam") + True + >>> is_palindrome("hello") + False + >>> is_palindrome("racecar") + True + >>> is_palindrome("12321") + True + """ + normalized = input_string.lower().replace(" ", "") + return normalized == normalized[::-1]