Nine Counter
Lists often need a count of one specific value, such as a score, error code, or target number. Write a function array_count9 that takes a list of numbers nums and returns how many elements are equal to 9. Go through the list and increase the counter each time you find a nine.
Примеры
Ввод
[1, 2, 9]Вывод
1Ввод
[1, 9, 9]Вывод
2Ввод
[1, 9, 9, 3, 9]Вывод
3Нужно реализовать
def array_count9(nums: list[int]) -> int:
Теги
listsarray
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
[1,2,9]Expected
12
Input
[1,9,9]Expected
23
Input
[1,9,9,3,9]Expected
34
Input
[]Expected
05
Input
[1,2,3]Expected
06
Input
[2,10,10]Expected
0Focus radio
Paused · SomaFM · Fluid