Objective
Rotating a list k positions to the right means the last k elements move to the front. Slicing lets you do it without loops.
Instructions
- Read a line of space-separated items and then an integer
k(it may be larger than the length). - Show the list rotated
kpositions to the right, with the items separated by spaces. If the list is empty, show an empty line.
1 2 3 4 5
2
4 5 1 2 3
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise