Double the List
This kind of transformation is common when you need to process every item in a list the same way, such as doubling each value. Write a function maps that takes a list of integers a and returns a new list. Each element in the new list should be the matching original number multiplied by 2.
Примеры
Ввод
[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
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
[1,2,3]Expected
[2,4,6]2
Input
[4,1,1,1,4]Expected
[8,2,2,2,8]3
Input
[2,2,2,2,2]Expected
[4,4,4,4,4]4
Input
[]Expected
[]5
Input
[-1,0,5]Expected
[-2,0,10]6
Input
[1,2,3,1]Expected
[2,4,6,2]Focus radio
Paused · SomaFM · Fluid