From f8671d8803687ec00bcb7974ab4c6a75208720eb Mon Sep 17 00:00:00 2001 From: TharunBR Date: Wed, 23 Jul 2025 00:49:26 +0530 Subject: [PATCH] Add palindrome program --- palindrome.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 palindrome.py diff --git a/palindrome.py b/palindrome.py new file mode 100644 index 00000000000..7be1c01c05d --- /dev/null +++ b/palindrome.py @@ -0,0 +1,16 @@ +def is_palindrome(text): + text=text.lower() + + cleaned="" + for char in text: + if char.isalnum(): + cleaned+=char + + reversed_text=cleaned[::-1] + return cleaned== reversed_text + +user_input=input("Enter a word or a sentence:") +if is_palindrome(user_input): + print("It's a palindrome") +else: + print("It's not a palindrome")