From 4b78c6952d589e745b2ca5b4808835e1b496423b Mon Sep 17 00:00:00 2001 From: Muhammad Umer Farooq Date: Sun, 19 Apr 2020 12:35:36 -0400 Subject: [PATCH] Create is_palindrome.py (#1754) * Create is_palindrome.py * Update is_palindrome.py * Update is_palindrome.py Co-authored-by: Christian Clauss --- strings/is_palindrome.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 strings/is_palindrome.py diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py new file mode 100644 index 000000000..3070970ca --- /dev/null +++ b/strings/is_palindrome.py @@ -0,0 +1,19 @@ +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")