# Program to check given string is anagram of palindromic or not in Python

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

Suppose we have a string s, we have to check whether any permutation of s is a palindrome or not.

So, if the input is like s = "admma", then the output will be True, as we can rearrange "admma" to "madam" which is a palindrome.

To solve this, we will follow these steps −

• c := a map holding each individual character count of s
• count := 0
• for each i in list of all values of c, do
• if i is odd, then
• if count is same as 0, then
• count := count + 1
• come out from the loop
• return False
• return True

Let us see the following implementation to get better understanding −

## Example

Live Demo

from collections import Counter
class Solution:
def solve(self, s):
c = Counter(s)
count = 0
for i in c.values():
if i % 2 != 0:
if count == 0:
count += 1
continue
return False
return True
ob = Solution()
print(ob.solve(s))
"admma"
True