Kodewick
Start learning →
Starter←→0 / 80

Juice bar orders

#071StarterComprehensionsLists3 min

The juice bar's orders are a list of (juice, cups). Write cups_of(orders, drink) to work out, in one line, how many cups of drink were ordered. If nobody ordered it, that's 0.

Examples
cups_of([("mango", 2), ("lime", 1), ("mango", 3)], "mango")→5
cups_of([], "lime")→0
main.py
def cups_of(orders, drink):
    # your code here: one line: add up the cups of this juice and return it (instead of return 0)
    return 0
Ctrl + Enter runs too
Result

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