Write a python function to count how many times the predicate is true


Topic: Write a python function to count how many times the predicate is true

Solution

def quantify(iterable, pred=bool):
    return sum(map(pred, iterable))



List all Python Programs