PRACTICE

Formatting Numbers

Lesson notes

Your task

Set total to 1234.5. Print it as dollars with a thousands separator and two decimals, like $1,234.50.

Expected output
$1,234.50
Loading…

OUTPUT

Worked solution
total = 1234.5
print(f"${total:,.2f}")

Checks compare printed output, not your approach. Several solutions can be valid.

← Back to courses