Line Up the Price List
Python
25 pts
Line Up the Price List
Create three strings with f-strings so the price list lines up in two columns:
header— the textItemleft-aligned in 10 characters, thenPriceright-aligned in 8 charactersrow1—item1left-aligned in 10, thenprice1right-aligned in 8 with 2 decimal placesrow2— the same foritem2andprice2
Print the three strings. Expected output:
Item Price Shiro 45.00 Coffee 8.50
Checklist
- Keep the items and prices unchanged and create
header:Itemleft-aligned in 10,Priceright-aligned in 8. - Create
row1foritem1andprice1, with the price showing 2 decimal places. - Create
row2the same way foritem2andprice2. - Print
header,row1androw2.
🔑 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.
