From 02e47d9ffbdbb8db5eb32dd948a1302a947c0d30 Mon Sep 17 00:00:00 2001 From: Mamtesh2001 Date: Wed, 5 Nov 2025 16:02:47 +0530 Subject: [PATCH] Fix: add doctests and descriptive parameter for is_palindrome --- strings/is_palindrome.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 strings/is_palindrome.py 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]