Last Value Keeper

This is good practice for creating a new list of the right length and handling the last element carefully. Write a function make_last that takes a non-empty list nums of length n. Return a new list of length 2n where every element is 0, except the very last one, which should equal the last element of the original list.

Примеры

Ввод
[4, 5, 6]
Вывод
[0, 0, 0, 0, 0, 6]
Ввод
[1, 2]
Вывод
[0, 0, 0, 2]
Ввод
[3]
Вывод
[0, 3]

Нужно реализовать

def make_last(nums: list[int]) -> list[int]:

Теги

listsarray
PostgreSQLv16

Siia ilmub koodi käivituse tulemus

Visible tests
1
Input
[4,5,6]
Expected[0,0,0,0,0,6]
2
Input
[1,2]
Expected[0,0,0,2]
3
Input
[3]
Expected[0,3]
4
Input
[0,0,9]
Expected[0,0,0,0,0,9]
5
Input
[7,1]
Expected[0,0,0,1]
6
Input
[6,5,4]
Expected[0,0,0,0,0,4]
Focus radio
Paused · SomaFM · Fluid