given two strings write a program to determine if a string s2 is a rotation of another string s1 in python in easy method
def is_rotation(string1, string2):
size1 = len(string1)
size2 = len(string2)
temp = ''
if size1 != size2:
return '{} is not a rotation of {}'.format(string1, string2)
temp = string1 + string1
if temp.count(string2) > 0:
return '{} is a rotation of {}'.format(string1, string2)
else:
return '{} is not a rotation of {}'.format(string1, string2)
is_rotation('AACD', 'ACDA')
'AACD is a rotation of ACDA'
Comments
Leave a comment