Kodewick
学びはじめる →
ミニチャレンジ←0 / 100

カフェの注文合計

#100ミニチャレンジ約 8 分

注文は "Latte, muffin, latte" のように、カンマで区切った 1 行で届きます。大文字やスペースはばらばらです。menu は辞書(小文字の名前 → 値段)です。合計を返す order_total(menu, order) を書きましょう。メニューにないものは飛ばし、空の注文は 0 です。

例
order_total({"latte": 18, "muffin": 12, "tea": 10}, "Latte, muffin, latte")→48
order_total({"latte": 18, "tea": 10}, "TEA, pizza ")→10
order_total({"latte": 18}, "")→0
main.py
def order_total(menu, order):
    total = 0
    for item in order.split(","):
        name = item.strip().lower()
        # ここにコードを書く:name がメニューにあれば値段を足す
        pass
    return total
Ctrl + Enter でも実行できます
結果

実行すると例で試せます。よさそうなら提出しましょう。