Kodewick
Start learning →
Mini challenge←→0 / 100

Snack receipt

#076Mini challengeFunctionsMixed6 min

A snack shop receipt has lines of [price, qty]. First write line_total(price, qty) for one line, then receipt_total(lines) to add up every line with it. A total of 100 or more gets 10 off. No lines costs 0.

Examples
receipt_total([[5, 2], [3, 4]])→22
receipt_total([[30, 2], [20, 2]])→90
main.py
def line_total(price, qty):
    # your code here: what one line costs
    return 0

def receipt_total(lines):
    total = 0
    for price, qty in lines:
        total += line_total(price, qty)
    # your code here: 100 or more gets 10 off

    return total
Ctrl + Enter runs too
Result

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