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
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible 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