Kodewick
Start learning →
Starter←→0 / 80

Scoops left

#030StarterDicts3 min

The ice cream van keeps a note of scoops left for each flavor: {flavor: scoops}. Write scoops_left(freezer, flavor) to return how many scoops of that flavor are left. If the flavor is not in the freezer at all, return 0.

Examples
scoops_left({"vanilla": 5, "mango": 2}, "mango")→2
scoops_left({"vanilla": 5}, "mint")→0
main.py
def scoops_left(freezer, flavor):
    left = 0
    # your code here: look up the flavor with get, 0 if it is not there
    return left
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.