You are viewing a single comment's thread. Return to all comments →
WHat if d is larger than n?
d is always smaller than or equal to n, see the constraints
Same idea, but if d is an integer with no restrictions, this works:
shifted = a[d%n:] + a[:d%n]
for num in shifted:
print(num, end=' ')