Calindrome string in python by R4R Team

String are said to be calindrome if
-It is palindrome
-and length of string is multiple of 6.

Example-

"abccba" is calindrome string.

"xyzyx" is not calindrome string.


program-

#take string input
print("Enter string")
s1=input()

#reverse string and store in other string
s2=s1[::-1]

#check for calindrome
if s2==s1 and len(s1)%6==0:
print("String is calindrome")
else:
print("String is not calindrome")


output-

Enter string
xyzzyx
String is calindrome

Enter string
abcba
String is not calindrome


-In this program, we take an input of string, and we reverse the string by slicing [::-1], then we compare both string and length is multiple of 6 is not.




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!