Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

palindrom python rekursiv

def ispalindrome(word):
    return word == word[::-1]
Comment

palindrom python rekursiv

def ispalindrome(word):
    if len(word) < 2: return True
    if word[0] != word[-1]: return False
    return ispalindrome(word[1:-1])
Comment

PREVIOUS NEXT
Code Example
Python :: filter in python 
Python :: export postgres database to heroku 
Python :: pygame rect 
Python :: pyside click through window 
Python :: python redis delete many 
Python :: extracting values in pandas 
Python :: add a constant to a list python 
Python :: how to perform group by with django orm 
Python :: python how to use rnage 
Python :: dockerize django 
Python :: django annotate 
Python :: pandas read csv with lists 
Python :: elbow plot for k means clustering 
Python :: dictionary input from user in python3 
Python :: python codes for counting the occurrence of a letters in dictionary excluding digits 
Python :: how to run python code in python 
Python :: post from postman and receive in python 
Python :: python sort a list using defined order 
Python :: find index of value in list python 
Python :: range in python 
Python :: python get all combinations of n numbers 
Python :: python django login register 
Python :: add vertical line in plot python 
Python :: dataframe select row by index value 
Python :: python environment 
Python :: add element to list 
Python :: what does the .item() do in python 
Python :: join function in python 
Python :: python interview questions and answers pdf 
Python :: python print every row of dataframe 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =