I am trying to switch the first character in a string and move it to the end of the string. It needs to repeat the rotation a number of n times.
For example, rotateLeft(hello,2)=llohe
.
I tried doing
def rotateLeft(str,n):
rotated=""
rotated=str[n:]+str[:n]
return rotated
Is this right, and how would you do it if it remove the last character and move it to the front of the string?