Skip to content

Commit 13d2cc1

Browse files
committed
Add palindrome check algorithm in strings/
1 parent c0ad5bb commit 13d2cc1

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

strings/is_palindrome.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def is_palindrome(text: str) -> bool:
2+
"""
3+
Check if a string is a palindrome.
4+
>>> is_palindrome("radar")
5+
True
6+
>>> is_palindrome("hello")
7+
False
8+
"""
9+
return text == text[::-1]
10+
11+
12+
if __name__ == "__main__":
13+
import doctest
14+
doctest.testmod()

0 commit comments

Comments
 (0)