Palindrome string in python by R4R Team

Palindrome string -
A string is said to be a palindrome if string and it's reverse are equal,like an example "oldlo" is a palindrome string because it reverse is also 'oldlo'

program -

print("Enter string")
s=input()
#reverse the string
s1=s[::-1]
if s==s1:
print("palindrome")
else:
print("Not palindrome")


output -

Enter string
oldlo
palindrome


Enter string
hello
Not palindrome


-In this program, we take string as a input and reverse that string by s[::-1] and store in s1 then we compare both, if they are same then print palindrome otherwise it is not palindrome.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!