W3docs

How to print a number using commas as thousands separators

In Python, you can use the built-in function format() to print a number with commas as thousands separators.

In Python, you can use the built-in function format() to print a number with commas as thousands separators. Here is an example:

Print a number using commas as thousands separators in Python with format method

python— editable, runs on the server

This will output:


1,234,567

You can also use the f-string (f"")

Print a number using commas as thousands separators in Python with f-strings

python— editable, runs on the server

This will also output:


1,234,567