Skip to content

Commit 4b78c69

Browse files
lablnetcclauss
andauthored
Create is_palindrome.py (#1754)
* Create is_palindrome.py * Update is_palindrome.py * Update is_palindrome.py Co-authored-by: Christian Clauss <[email protected]>
1 parent c92a520 commit 4b78c69

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

strings/is_palindrome.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def is_palindrome(s):
2+
"""
3+
Determine whether the string is palindrome
4+
:param s:
5+
:return: Boolean
6+
>>> is_palindrome("a man a plan a canal panama".replace(" ", ""))
7+
True
8+
>>> is_palindrome("Hello")
9+
False
10+
"""
11+
return s == s[::-1]
12+
13+
14+
if __name__ == "__main__":
15+
s = input("Enter string to determine whether its palindrome or not: ").strip()
16+
if is_palindrome(s):
17+
print("Given string is palindrome")
18+
else:
19+
print("Given string is not palindrome")

0 commit comments

Comments
 (0)