runtime
336 / 500
question 336 Functional & Dynamic Python · medium

Nutrient checks built in a loop

make_checks(limits) builds one check function per nutrient, and flags(product, checks) lists the nutrients a product is over. Every product is flagged for every nutrient, and when that is fixed, the checks all compare against the last nutrient in limits. Fix both bugs.

make_checks(limits)returns {nutrient: function(product) -> bool}, true when the product's value is over that nutrient's limit
flags(product, checks)the names of the checks that are true for the product, in order
Missing valuesa missing nutrient is not over the limit

Loading your progress…

Nutrient checks built in a loop — Python practice · Runtime