Write a Python Function to rotate string left and right by d length
Topic: Write a Python Function to rotate string left and right by d length
Solution
def rotate(input,d): Lfirst = input[0 : d] Lsecond = input[d :] Rfirst = input[0 : len(input)-d] Rsecond = input[len(input)-d : ] print ("Left Rotation : ", (Lsecond + Lfirst) ) print ("Right Rotation : ", (Rsecond + Rfirst)) input = 'GeeksforGeeks' d=4 rotate(input,d)
List all Python Programs