1def rotate_string(s,d):
2
3 # slice string in two parts for left and right
4 Lfirst = s[0 : d]
5 Lsecond = s[d :]
6 Rfirst = s[0 : len(s)-d]
7 Rsecond = s[len(s)-d : ]
8
9 # now join two parts together
10 print ("Left Rotation : ", (Lsecond + Lfirst) )
11 print ("Right Rotation : ", (Rsecond + Rfirst))
12
13string = 'Studytonight'
14d=4
15rotate_string(string,d)