We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent af17867 commit bae8da0Copy full SHA for bae8da0
strings/is_palindrome.py
@@ -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
20
+ >>> is_palindrome("12321")
21
22
23
+ normalized = input_string.lower().replace(" ", "")
24
+ return normalized == normalized[::-1]
0 commit comments