def palindromeRearranging(inputString):
return sum(map(lambda x: inputString.count(x) % 2, set(inputString))) <= 1
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
a=input('enter a string :')# palindrome in string
b=a[::-1]
if a==b:
print(a,'is a palindrome')
else:
print(a,'is not a palindrome')
print('a is not equal to b')
if a!=b:
print(b, 'the reverse of', a)
#output:
--------------------------------------------------------------------------------
case-I
# not palindrome
enter a string :1254
1254 is not a palindrome
a is not equal to b
4521 the reverse of 1254
--------------------------------------------------------------------------------
case-II
# palindrme
enter a string :12321
12321 is a palindrome
is_palindrome = lambda phrase: phrase == phrase[::-1]
print(is_palindrome('anna')) # True
print(is_palindrome('rats live on no evil star')) # True
print(is_palindrome('kdljfasjf')) # False
def check_palindrome_1(string):
reversed_string = string[::-1]
status=1
if(string!=reversed_string):
status=0
return status
string = input("Enter the string: ")
status= check_palindrome_1(string)
if(status):
print("It is a palindrome ")
else:
print("Sorry! Try again")