Double the List
Write a function maps that takes a list of integers a and returns a new list where each element is the original number multiplied by 2. For an empty list, return an empty list. An empty list [] and the append method inside a loop will help.
Примеры
Ввод
[1, 2, 3]Вывод
[2, 4, 6]Ввод
[4, 1, 1, 1, 4]Вывод
[8, 2, 2, 2, 8]Ввод
[2, 2, 2, 2, 2]Вывод
[4, 4, 4, 4, 4]Нужно реализовать
def maps(a: list[int]) -> list[int]:
Теги
listsarray
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inTests12
Visible tests
Dolt test 7
Dolt test 8
Dolt test 9
Dolt test 10
Dolt test 11
Dolt test 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid