top of page

Program in Python to check whether given Number or String is Palindrome or Not?

Updated: Dec 16, 2021

Program to check whether given String is palindrome or not?


Code:

string=input(("Enter a letter:"))  
if(string==string[::-1]):  
      print("The letter is a palindrome")  
else:  
      print("The letter is not a palindrome") 

Output:

ree

ree


Program to check whether given Integer is Palindrome or not?


Code:

n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
    dig=n%10
    rev=rev*10+dig
    n=n//10
if(temp==rev):
    print("The number is a palindrome!")
else:
    print("The number isn't a palindrome!")  

Output:

ree

ree


Read More:



The Tech Platform

 
 
 

1 Comment


Guest
Nov 12

I've been engrossed in Steal a Brainrot lately, exploring its intricate puzzles and captivating storyline. The way Steal a Brainrot challenges my problem-solving skills is truly exhilarating. Have you encountered the secret level in Steal a Brainrot yet? It's mind-boggling!

Like
bottom of page