def order_total(items, coupon): total = 0 for x in items: price = get_price(x["id"]) total = total + price * x["qty"] if coupon: total = total - get_coupon(coupon)["amount"] return total