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
Accedi per vedere la cronologia degli invii
AccediAccedi per usare l'AI Mentor
AccediVisible tests
1
Input
[1,2,3,4]Expected
[2,2]2
Input
[]Expected
[0,0]3
Input
[2,4,6]Expected
[3,0]4
Input
[1,3,5]Expected
[0,3]5
Input
[0]Expected
[1,0]6
Input
[0,0,0,0]Expected
[4,0]Focus radio
Paused · SomaFM · Fluid