True Counter
Lists often store the results of checks: a test passed, a setting is enabled, or a match was found. Write a function count_truthy that takes a list arr of boolean values. Return how many times True appears in the list.
Примеры
Ввод
[True, False, True, True]Вывод
3Ввод
[]Вывод
0Ввод
[False, False, False]Вывод
0Нужно реализовать
def count_truthy(arr: list) -> int:
Теги
listsarraymath
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 isteachVisible tests
1
Input
[true,false,true,true]Expected
32
Input
[]Expected
03
Input
[false,false,false]Expected
04
Input
[true]Expected
15
Input
[true,true,false,true,false]Expected
36
Input
[true,true,false,true]Expected
3Focus radio
Paused · SomaFM · Fluid