forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5aa9a00
commit 40c7b84
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |