Editor

Format a Large Number with Commas

Beginner · Write the code · from Python String Formatting: f-strings, format(), and % Operator

From the lesson: Python String Formatting: f-strings, format(), and % Operator

Imagine you're building a receipt for a coffee shop. You need to combine a product name, a price, and a quantity into one clean line. You could glue strings together with +, but it gets messy fast.

Read the lesson

Create a variable population set to 7900000000. Print it using an f-string with comma separators so the output is:

World population: 7,900,000,000
# Format the population with commas

More String Formatting exercises

All Python exercises · 50 practice problems · Python Fundamentals quiz