Skip to content

Commit 4f97b9a

Browse files
Merge pull request #2799 from TharunBR/master
Add palindrome checker script
2 parents ec1a395 + f8671d8 commit 4f97b9a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

palindrome.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def is_palindrome(text):
2+
text=text.lower()
3+
4+
cleaned=""
5+
for char in text:
6+
if char.isalnum():
7+
cleaned+=char
8+
9+
reversed_text=cleaned[::-1]
10+
return cleaned== reversed_text
11+
12+
user_input=input("Enter a word or a sentence:")
13+
if is_palindrome(user_input):
14+
print("It's a palindrome")
15+
else:
16+
print("It's not a palindrome")

0 commit comments

Comments
 (0)