question 92 Fundamentals Integration · easy
Members are charged less every time the page refreshes
basket_total(lines, member=False) should return the basket's total, with 10% off every line for members except clearance lines, which never get the member discount. The checkout page calls it once to show the total and again to charge the card, and members are charged less the second time. Clearance items are being discounted too. Fix both bugs.
Function
basket_total(lines, member=False)linesa list of dictionaries with
"quantity", "price" and "clearance" (True or False)Returnsthe sum of quantity × price, with members paying 90% of the price on non-clearance lines
Must notchange any line
Examples
callbasket_total([{'quantity': 2, 'price': 15.0, 'clearance': False}, {'quantity': 1, 'price': 8.0, 'clearance': True}], True)returns35.0
callbasket_total([{'quantity': 2, 'price': 15.0, 'clearance': False}], False)returns30.0
callbasket_total([], True)returns0