Rotate Array Right

Rotate array elements to the right by a specified number of positions, wrapping elements around.

Code

General
k = n % len(arr)
arr[-k:] + arr[:-k]

Parameters

Array to rotate

Positions to rotate

Server

More Python Snippets