Skip to content

Commit 02e47d9

Browse files
author
Mamtesh2001
committed
Fix: add doctests and descriptive parameter for is_palindrome
1 parent af17867 commit 02e47d9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

strings/is_palindrome.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def is_palindrome(input_string: str) -> bool:
2+
"""
3+
Check if a given string is a palindrome.
4+
5+
A palindrome is a string that reads the same forward and backward.
6+
7+
Args:
8+
input_string (str): The string to check.
9+
10+
Returns:
11+
bool: True if the string is a palindrome, False otherwise.
12+
13+
Examples:
14+
>>> is_palindrome("madam")
15+
True
16+
>>> is_palindrome("hello")
17+
False
18+
>>> is_palindrome("racecar")
19+
True
20+
>>> is_palindrome("12321")
21+
True
22+
"""
23+
normalized = input_string.lower().replace(" ", "")
24+
return normalized == normalized[::-1]

0 commit comments

Comments
 (0)