Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions strings/is_palindrome.py
Original file line number Diff line number Diff line change
@@ -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]