Objective
Create a Python program that prints a receipt with well-aligned columns using f-string formatting.
Instructions
- Read an integer
nand thennlines with the formatproduct price(the product is a single word and the price a decimal number). - Show one line per product: the name left-aligned in 12 positions and the price right-aligned in 8 positions with two decimals (
{name:<12}{price:>8.2f}). - Then show a line with 20 hyphens (
-). - Finish with a
TOTALline with the same format, with the sum of the prices.
3
pan 1.2
leche 0.95
huevos 2.35
pan 1.20
leche 0.95
huevos 2.35
--------------------
TOTAL 4.50
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise