Count Enabled Flags
Boolean values often work like flags: True means yes or enabled, and False means no or disabled. The function count_true receives a list of boolean values flags and counts how many of them are True. If the list is empty or has no enabled flags, return 0.
Примеры
Ввод
[True, False, True]Вывод
2Ввод
[]Вывод
0Ввод
[False, False]Вывод
0Нужно реализовать
def count_true(flags: list[bool]) -> int:
Теги
lists
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
[true,false,true]Expected
22
Input
[]Expected
03
Input
[false,false]Expected
04
Input
[true,true,true]Expected
35
Input
[true]Expected
16
Input
[true,false,true,true]Expected
3Focus radio
Paused · SomaFM · Fluid