after arrange palindrome python code example

Example 1: 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

Example 2: palindrome python

#A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward.
#Ex: madam or racecar.
def is_palindrome(w):
	if w==w[::-1]: # w[::-1] it will reverse the given string value.
		print("Given String is palindrome")
	else:
		print("Given String is not palindrome")

is_palindrome("racecar")

Tags:

Cpp Example