Created
February 5, 2020 04:06
-
-
Save carlessanagustin/1c8dfa6761eb74579394f17b9316fb25 to your computer and use it in GitHub Desktop.
Rotate string in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rotateL(input,d): | |
Lfirst = input[0 : d] | |
Lsecond = input[d :] | |
return (Lsecond + Lfirst) | |
def rotateR(input,d): | |
Rfirst = input[0 : len(input)-d] | |
Rsecond = input[len(input)-d : ] | |
return (Rsecond + Rfirst) | |
print (rotateL("hello",2)) | |
print (rotateR("hello",2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment