Skip to content

Commit 47e4aca

Browse files
committed
palindrome
1 parent a05c40a commit 47e4aca

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

useful_scripts/palindrome.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Sebastian Raschka 04/2014
2+
3+
def palindrome(my_str):
4+
"""
5+
Returns True if an input string is a palindrom
6+
"""
7+
stripped_str = "".join([l.lower() for l in my_str if l.isalpha()])
8+
return stripped_str == stripped_str[::-1]
9+
10+
if __name__ == '__main__':
11+
test1 = 'Hello World!'
12+
test2 = "Go hang a salami. I'm a lasagna hog."
13+
print('test1', palindrome(test1))
14+
print('test2', palindrome(test2))

0 commit comments

Comments
 (0)