Python
# Program to check if one string is a rotation of another
s1 = input("Enter first string: ")
s2 = input("Enter second string: ")
if len(s1) != len(s2):
print("Not rotations (different lengths).")
else:
if s2 in (s1 + s1):
print("Strings are rotations of each other.")
else:
print("Strings are not rotations of each other.")Output
Enter first string: ABCD Enter second string: CDAB Strings are rotations of each other.
If s2 is a rotation of s1, it must appear as a substring inside s1 + s1.