Rotate a list right by 1
Input
rotate([1, 2, 3, 4], 1)
Output
[4, 1, 2, 3]
Right rotation by 1 moves the last element to the front.
Full lesson preview
Use collections.deque.rotate to rotate sequences efficiently and preserve type.
Problem statement
Task
Examples
Input
rotate([1, 2, 3, 4], 1)
Output
[4, 1, 2, 3]
Right rotation by 1 moves the last element to the front.
Input format
Output format
Constraints
Samples
Input
rotate('abcd', 2)
Output
cdab
Right rotate string by 2: 'ab' moves to the end, resulting in 'cdab'.