Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
Source by www.kdnuggets.com #
 
PREVIOUS NEXT
Tagged: #palindrome #string #python
ADD COMMENT
Topic
Name
3+5 =