← Back to challenges

How Much is True?

PythonMediumarrayslanguage_fundamentals

Instructions

Create a function which returns the number of True values in a list.

Examples

count_true([True, False, False, True, False]) ➞ 2

count_true([False, False, False, False]) ➞ 0

count_true([]) ➞ 0

Notes

  • Return 0 if given an empty list.
  • All list items are of the type bool (True or False).
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Tile Teamwork Tactics