mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-30 16:31:08 +00:00
4b78c6952d
* Create is_palindrome.py * Update is_palindrome.py * Update is_palindrome.py Co-authored-by: Christian Clauss <cclauss@me.com>
20 lines
503 B
Python
20 lines
503 B
Python
def is_palindrome(s):
|
|
"""
|
|
Determine whether the string is palindrome
|
|
:param s:
|
|
:return: Boolean
|
|
>>> is_palindrome("a man a plan a canal panama".replace(" ", ""))
|
|
True
|
|
>>> is_palindrome("Hello")
|
|
False
|
|
"""
|
|
return s == s[::-1]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
s = input("Enter string to determine whether its palindrome or not: ").strip()
|
|
if is_palindrome(s):
|
|
print("Given string is palindrome")
|
|
else:
|
|
print("Given string is not palindrome")
|