print all palindrome string made by rearrange of string elements in python code example
Example 1: string palindrome in python
n = input("Enter the word and see if it is palindrome: ")
if n == n[::-1]:
print("This word is palindrome")
else:
print("This word is not palindrome")
Example 2: palindrome rearranging python
import collections
def palindromeRearranging(inputString):
cnt = collections.Counter()
odds = 0
for i in range(len(inputString)):
cnt[inputString[i]] += 1
for i in cnt:
if cnt[i]%2 == 1:
odds += 1
return odds <= 1