Why does this python left rotation of an array not work
Now that you have solved it, I can add a couple of other solutions.
First a simple one:
def rotLeft1(a):
return a[1:] + [a[0]]
def rotLeft(a, d):
for _ in range(d):
a = rotLeft1(a)
return a
Then one that doesn't make one step at a time:
def rotLeft(a, d):
i = d % len(a)
return a[i:] + a[:i]