Count palindrome words(Case Insensitive)
Problem to find the number of palindrome words in given string(Case Insensitive).
Example-1:
Input : s = "I love my Mom And Dad" Output : 3 Explain : There are three palindrome words in given string "I","Mom","Dad".
Example-2:
Input : s = "Wow your eye is beautiful". Output : 2 Explain : There are two palindrome words in given string "Wow","eye".
Solution
s = "I love my Mom And Dad" s = s.split() k = 0 for x in s: if(x.casefold()==x.casefold()[::-1]): k += 1 print(k)
Output
3