Every Line, Discounted

Data with PythonMedium+10 XP+10

Every Line, Discounted

A shop's till works out a receipt one line per product. For product i:

  • prices[i] is the price of one item,
  • quantities[i] is how many were bought,
  • discounts[i] is that product's discount, as a percentage. 10 means 10% off, and 0 means no discount.

A line's total is the price times the quantity, with the discount taken off.

Task: write line_totals(prices, quantities, discounts) and return every line's total as a plain list, in the same order. Don't round.

If the three lists are not all the same length, the receipt is broken. Return None instead.

Examples

prices = [2.0, 3.5, 4.0]
quantities = [3, 2, 5]
discounts = [10, 0, 50]
returns [5.4, 7.0, 10.0]
prices = [1.2, 0.8]
quantities = [4, 10]
discounts = [0, 25]
returns [4.8, 6.0]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run