How to Use Underscores to Format Large Numbers in Python

When working with a large number in Python, it can be difficult to figure out how many digits that number has. Python 3.6 and above allows you to use underscores as visual separators to group digits.

In the example above, I use underscores to group decimal numbers by thousands.

Link to the source code.

Scroll to Top