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.
receipt_total([[5, 2], [3, 4]])→22receipt_total([[30, 2], [20, 2]])→90def 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
Run tries the examples. When they look right, Submit.