Problem 155953 · easy · Phase 01 Prerequisites & Setup

Money with Thousands Separators

functions · f-strings · string formatting

Write pretty_money(amount) that returns a non-negative amount as a string with a leading $, commas every three digits, and exactly two decimals.

Examples

Input:  amount = 1234.5
Output: "$1,234.50"
Input:  amount = 0
Output: "$0.00"

Constraints

  • 0 <= amount <= 10**12

Goals

  • Use the comma format option for thousands separators
  • Combine it with a fixed number of decimals
Starting Python…