Answer to Question #231278 in Python for bhuvana

Question #231278

Given two strings(S1 and S2), write a program to determine if a string S2 is a rotation of another string S1.


1
Expert's answer
2021-09-10T01:50:00-0400
string1 = "XXYZ"
string2 = "XYZX"


print("String-1: ",string1)
print("String-2: ",string1)
s1 = len(string1)
s2 = len(string2)
temp = ''
 
if(s1 != s2):
    print ("\nStrings are NOT rotations of each other: Reason: String's sizes are different.")  
 
tempString = string1 + string1
 
if(tempString.count(string2)> 0):
    print ("\nStrings are rotations of each other")  
else:
    print ("\nStrings are not rotations of each other")




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS