Duplicate Each Item

Sometimes you need to duplicate data while keeping the original order, like making two identical cards in a row. Given a stack stack represented as a list, return a new list where each element appears twice consecutively. If the stack is empty, return an empty list.

Примеры

Ввод
[3, 7, 1, 14, 9]
Вывод
[3, 3, 7, 7, 1, 1, 14, 14, 9, 9]
Ввод
[]
Вывод
[]
Ввод
[5]
Вывод
[5, 5]

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

def stutter(stack: list[int]) -> list[int]:

Теги

stack
PostgreSQLv16

Hawn jidher ir-riżultat tat-tħaddim tal-kodiċi

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