Kodewick
Start learning →
Starter←→0 / 100

Sold a few

#058StarterDicts3 min

The fruit stall keeps its stock in a dict of fruit to count. Write sell(stock, fruit, n): n of fruit were sold, so take them off its count and return the updated dict. fruit is always in the dict.

Examples
sell({"apple": 10, "pear": 4}, "apple", 3)→{'apple': 7, 'pear': 4}
sell({"apple": 10, "pear": 4}, "pear", 4)→{'apple': 10, 'pear': 0}
main.py
def sell(stock, fruit, n):
    # your code here: take n off the count of fruit

    return stock
Ctrl + Enter runs too
Result

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