livepython.net

107. Python Program to Format a Number with Commas

EasyFormatting

Overview

Use f-string number formats to make a big amount easy to read.

Problem Statement

Read an amount (it may have decimals) and print it with a comma between every group of three digits and exactly two decimal places. For example, for 1234567.5:

Amount: 1,234,567.50

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One number. Example:

1234567.5

Output

The output for that example:

Amount: 1,234,567.50

The tests try 4 different inputs, including a small one with no commas at all.

Learn this firstChapter 12 · Python f-string Formatting: Width, Align, Commas
solution.py
# write your code here

EXPECTED OUTPUT

1Amount: 1,234,567.50

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.