Left Turn
Rotating a list is like a carousel: the first element moves to the end, and the others shift left. Write a function rotate_left3 that takes a list nums with exactly three numbers. Return a new list where the elements appear in this order: second, third, first.
Примеры
Ввод
[1, 2, 3]Вывод
[2, 3, 1]Ввод
[5, 11, 9]Вывод
[11, 9, 5]Ввод
[7, 0, 0]Вывод
[0, 0, 7]Нужно реализовать
def rotate_left3(nums: list[int]) -> list[int]:
Теги
listsarray
Log in om je inzendingsgeschiedenis te zien
InloggenLog in om de AI-mentor te gebruiken
InloggenVisible tests
1
Input
[1,2,3]Expected
[2,3,1]2
Input
[5,11,9]Expected
[11,9,5]3
Input
[7,0,0]Expected
[0,0,7]4
Input
[1,1,1]Expected
[1,1,1]5
Input
[0,0,0]Expected
[0,0,0]6
Input
[1,2,3,1,2]Expected
[2,3,1]Focus radio
Paused · SomaFM · Fluid