Step 5: Print a clear report
Numbers are only useful if people can read them. Build a small table with an f-string for each row: a header, a rule line, one row per region sorted by revenue, and a total row. A money() helper formats thousands separators and the dollar sign in one place.
Examplepython
Formatting helpers like money keep your code tidy: if the manager wants euros, you change one function.
Your turn: write the code
Write money(x) that formats a number with a dollar sign, thousands separators and two decimals. Print money(1234.5) and money(0.5).
Quick check
What does the format :,.2f do?
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.