runtime
148 / 500
question 148 Advanced Functions & Recursion · hard

Every validator checks the last limit

make_validators(limits) builds one check function per field of an order form, from a dictionary such as {"quantity": 10, "discount": 0.5}. Each check should return True when a value is at most its own field's limit. But every check behaves as if its limit were the last one in the dictionary: checks["quantity"](8) is False. Find out why and fix it.

Functionmake_validators(limits)
limitsa dictionary of field name → maximum allowed value
Returnsa dictionary of field name → function; checks[field](value) is True when value <= limits[field]
Keepthe function name and what it returns

Loading your progress…

Every validator checks the last limit — Python practice · Runtime