Shop Receipt
Python
25 pts
Shop Receipt
Define shop_receipt(customer, prices). customer is a name and prices is a list of prices in Nakfa. The function prints three lines:
Customer: Abel Items: 3 Total: 45 Nakfa
Use len() for the number of items and a for loop to add up the total. For an empty list it must print Items: 0 and Total: 0 Nakfa.
Call it once with "Abel" and [10, 15, 20] to get the output above.
Checklist
- Define
shop_receiptwith the parameterscustomerandprices. - Add up the prices with a
forloop and print the three receipt lines. - Make sure an empty list gives
Items: 0andTotal: 0 Nakfa. - Call the function with
"Abel"and[10, 15, 20].
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
