Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MaherAssaf19 authored Jan 12, 2025
1 parent 5aa9a00 commit 40c7b84
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions solutions/is_palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
A module to check if a given string is a palindrome.
Module contents:
- is_palindrome: checks if a string reads the same forwards and backwards.
Created on 03-01-25
"""


def is_palindrome(input_string: str) -> bool:
"""
Checks if a string is a palindrome.
Parameters:
input_string (str): The string to be checked.
Returns:
bool: True if the string is a palindrome, False otherwise.
Raises:
TypeError: If the input is not a string.
Examples:
>>> is_palindrome("madam")
True
>>> is_palindrome("hello")
False
>>> is_palindrome("")
True
"""
if not isinstance(input_string, str):
raise TypeError("Input must be a string.")
return input_string == input_string[::-1]

0 comments on commit 40c7b84

Please sign in to comment.