Skip to content

Commit c7b54a0

Browse files
committed
Add is_palindrome algorithm under strings category
1 parent 0c8cf8e commit c7b54a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

strings/is_palindrome.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def is_palindrome(txt):
2+
"""
3+
Checks if a given text is a palindrome.
4+
5+
A palindrome is a word or phrase that reads the same forwards and backwards.
6+
7+
Parameters:
8+
txt (str): The text to check.
9+
10+
Returns:
11+
bool: True if the text is a palindrome, False otherwise.
12+
"""
13+
return txt == txt[::-1]
14+
15+
print(is_palindrome("radar"))

0 commit comments

Comments
 (0)