Even Number Sum
Given a list of integers nums, choose only the even numbers and add them together. If there are no even numbers, or if the list is empty, the sum is 0. Return the final total.
Примеры
Ввод
[1, 2, 3, 4, 5, 6]Вывод
12Ввод
[1, 3, 5]Вывод
0Ввод
[]Вывод
0Нужно реализовать
def sum_even(nums: list[int]) -> int:
Теги
listsmath
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible tests
1
Input
[1,2,3,4,5,6]Expected
122
Input
[1,3,5]Expected
03
Input
[]Expected
04
Input
[2,3,4,5,6,7]Expected
125
Input
[0,0,0,0,0,0]Expected
06
Input
[1,2,3,4,5,6,1,2]Expected
14Focus radio
Paused · SomaFM · Fluid