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, rotateLef
rotateLef
I know this is old, but you can use collections.deque:
from collections import deque s = 'Impending doom approaches!' d = deque(s) d.rotate(11) print(''.join(d)) >>> approaches!Impending doom d.rotate(-21) print(''.join(d)) >>> doom approaches!Impending