Even Counter
Write a function count_evens that takes a list nums and counts how many even numbers it contains. Zero is also considered even. Return the number of values found. A for loop over the list, an if check inside the loop, and a counter for the values found will help.
Примеры
Ввод
[2, 1, 2, 3, 4]Вывод
3Ввод
[2, 2, 0]Вывод
3Ввод
[1, 3, 5]Вывод
0Нужно реализовать
def count_evens(nums: list[int]) -> int:
Теги
listsarray
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachTests12
Visible tests
Tástáil fholaithe 7
Tástáil fholaithe 8
Tástáil fholaithe 9
Tástáil fholaithe 10
Tástáil fholaithe 11
Tástáil fholaithe 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