#!/usr/bin/env python
# coding: utf-8
# # Palindrome Words using Python
# In[6]:
def palindrome(sentence):
for i in (",.'?/><}{{}}'"):
sentence = sentence.replace(i, "")
palindrome = []
words = sentence.split(' ')
for word in words:
word = word.lower()
if word == word[::-1]:
palindrome.append(word)
return palindrome
sentence = input("Enter a sentence : ")
print(palindrome(sentence))
#clcoding.com
# In[ ]:
0 Comments:
Post a Comment