The orchard weighs its apples; 200 grams or more counts as big. is_big and count_big are written. Finish count_if(items, check): check is a function, so call it on each item and count how many give True. An empty list gives 0.
count_big([180, 210, 200, 150])→2count_big([])→0def is_big(weight):
return weight >= 200
def count_if(items, check):
n = 0
for x in items:
# your code here: if check(x) is True, add 1 to n
pass
return n
def count_big(weights):
return count_if(weights, is_big)
Run tries the examples. When they look right, Submit.