Even and Odd Count
Counting even and odd numbers helps you quickly understand what a list is made of. The function count_even_odd receives a list of numbers nums and returns a list with two numbers. The first number is the count of even elements, and the second is the count of odd elements.
Примеры
Ввод
[1, 2, 3, 4]Вывод
[2, 2]Ввод
[]Вывод
[0, 0]Ввод
[2, 4, 6]Вывод
[3, 0]Нужно реализовать
def count_even_odd(nums: list[int]) -> list[int]:
Теги
listsmath
Prisijunkite, kad matytumėte pateikimų istoriją
PrisijungtiPrisijunkite, kad naudotumėte DI mentorių
PrisijungtiTests12
Visible tests
Paslėptas testas 7
Paslėptas testas 8
Paslėptas testas 9
Paslėptas testas 10
Paslėptas testas 11
Paslėptas testas 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