Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

palindrome Rearranging python one line

def palindromeRearranging(inputString):
    return sum(map(lambda x: inputString.count(x) % 2, set(inputString))) <= 1
Comment

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
Comment

palindrome string python

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
Comment

finding palindrome in python

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 
Comment

Palindrome in Python Using reverse function

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")
Comment

PREVIOUS NEXT
Code Example
Python :: insertion sort algorithm in descending order 
Python :: Load None python values to Databricks SQL Table 
Python :: continue loop django template 
Python :: open in new tab selenium python 
Python :: Square Odd Python 
Python :: Code Example of Comparing None with False type 
Python :: Python String count() Implementation of the count() method using optional parameters 
Python :: Accessing element using negative indexing 
Python :: foreach on sysargv 
Python :: python log max age linux delete old logs 
Python :: view(-1 1) pytorch 
Python :: code academy magic 8 bal code python 
Python :: word search engine in python 
Python :: get channel name by channel id discord py 
Python :: run flask in Jython 
Python :: ax text not placed correclty 
Python :: Python NumPy atleast_2d Function Example 
Python :: Django merge duplicate rows 
Python :: data framing with Pandas 
Python :: Python NumPy vstack Function Syntax 
Python :: catch all event on socketio python 
Python :: merge pdf with python at same page 
Python :: pyqt log widget thread safe 
Python :: how to increment date in python 
Python :: django view - apiview decorator (retrieve, update or delete - GET, PUT, DELETE) 
Python :: taking str input in python and counting no of it 
Python :: Creating a Nested Dictionary 
Python :: from android.runnable in python 
Python :: django.db.utils.ProgrammingError: (1146 
Python :: Library for removal of punctuation and defining function 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =