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
PostgreSQLv16

Le résultat de l'exécution du code s'affichera ici

Visible tests
1
Input
[true,false,true]
Expected2
2
Input
[]
Expected0
3
Input
[false,false]
Expected0
4
Input
[true,true,true]
Expected3
5
Input
[true]
Expected1
6
Input
[true,false,true,true]
Expected3
Focus radio
Paused · SomaFM · Fluid