Skip to content

Commit

Permalink
solved: How many are True? -@iamserda
Browse files Browse the repository at this point in the history
  • Loading branch information
iamserda committed Jan 19, 2025
1 parent 9e92d16 commit 8c29171
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions edabit/005_true_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Source: Edabit.com
Title: How Much is True?
Author: Joshua Señoron
Description: "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)."]
"""


def count_true(lst):
return len([x for x in lst if x == True])

0 comments on commit 8c29171

Please sign in to comment.