Write a function rotate_k(items, k) that returns a new sequence with the elements of
items rotated k places to the right: the last k elements move to the front.
k is first reduced modulo the length of items, so any integer works -- a k equal to
the length (or 0) leaves the sequence unchanged, and a negative k rotates to the left.
items is never empty.
Example
rotate_k([1, 2, 3, 4, 5], 2) -> [4, 5, 1, 2, 3]
rotate_k([1, 2, 3], 3) -> [1, 2, 3]
Implement this function:
def rotate_k(items, k: int = 1):
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: items, k.
Input
[1, 2, 3, 4, 5]
2
Output
[4, 5, 1, 2, 3]