The Tech Platform

Dec 15, 20211 min

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:

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:

Read More:

The Tech Platform

www.thetechplatform.com

    0