Remove the words that are palindrome in a given sentence
Ex:
Input: "He did a good deed"
output: "He good"
input: "Malayalam is my mother tongue"
output: " is my mother tongue"
Answers
Answered by
2
Answer:
def remove_palindrome(sntc):
word_list = sntc.split() #splitting the sentence in list of words
result = ""
for word in word_list: #traversing in word list
if word.lower() != word.lower()[::-1]: #checking each word for palindrome
result = result + word + " " #adding each non palindrome to result
return result
print(remove_palindrome("He did a good deed"))
print(remove_palindrome("Malayalam is my mother tongue"))
Explanation:
Similar questions
Hindi,
8 days ago
India Languages,
8 days ago
English,
16 days ago
Science,
16 days ago
Science,
9 months ago