Count the Sheep
In this list of marks, True means a sheep is present and False means it is missing. Write count_sheeps, which counts how many True values are in the list arr. If the list is empty or all values are False, the result should be 0.
Примеры
Ввод
[True, True, False, True]Вывод
3Ввод
[False, False]Вывод
0Ввод
[]Вывод
0Нужно реализовать
def count_sheeps(arr: list[bool]) -> int:
Теги
array
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
[true,true,false,true]Expected
32
Input
[false,false]Expected
03
Input
[]Expected
04
Input
[true,true,true]Expected
35
Input
[true,false,true,false,true]Expected
36
Input
[true,true,true,true,true]Expected
5Focus radio
Paused · SomaFM · Fluid