pyassistant

Rotate a list to the right by k steps

Given a list of integers and a non-negative integer k, return a new list with the elements rotated to the right by k steps. Rotating to the right by 1 moves each element one position to the right, and the last element becomes the first. If k is larger than the list length, it wraps around. An empty list should be returned unchanged.

Example:

Input:
([1, 2, 3, 4, 5], 2)
Output:
[4, 5, 1, 2, 3]

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.