human
Check if a string can be obtained by rotating another string 2 places | Function to check if string2 is obtained by string 1.
Initialize string as anti - clockwise rotation.
Initialize string as clock wise rotation.
check if any of them is equal to string1.
Driver code"
Solution in Python:
 Can you provide a code to check if a string can be obtained by rotating another string 2 places and the other steps required?
assistant
#Here is code to check if a string can be obtained by rotating another string 2 places and the other steps required.
 def isRotated ( str1 , str2 ) :
	if ( len ( str1 ) != len ( str2 ) ) :
		return False
	if ( len ( str1 ) < 2 ) :
		return str1 == str2
	clock_rot = " "
	anticlock_rot = " "
	l = len ( str2 )
	anticlock_rot = ( anticlock_rot + str2 [ l - 2 : ] + str2 [ 0 : l - 2 ] )
	clock_rot = clock_rot + str2 [ 2 : ] + str2 [ 0 : 2 ]
	return ( str1 == clock_rot or str1 == anticlock_rot )
if __name__ == " _ _ main _ _ " :
	str1 = " geeks "
	str2 = " eksge "
if isRotated ( str1 , str2 ) :
	print ( " Yes " )
else :
	print ( " No " )