果物屋さんは在庫を「果物 → 個数」の辞書で管理しています。sell(stock, fruit, n) を書きましょう。fruit が n 個売れたので、その個数から引いて、更新した辞書を返します。fruit は必ず辞書にあります。
sell({"apple": 10, "pear": 4}, "apple", 3)→{'apple': 7, 'pear': 4}sell({"apple": 10, "pear": 4}, "pear", 4)→{'apple': 10, 'pear': 0}def sell(stock, fruit, n):
# ここにコードを書く:fruit の個数から n を引く
return stock
実行すると例で試せます。よさそうなら提出しましょう。