Last active
October 29, 2021 10:54
-
-
Save kkroesch/a0a1829b79888bc11e638df07f37b4fb to your computer and use it in GitHub Desktop.
Readable large numbers in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Underscores in number literals are ignored: """ | |
| >>> ten_billion = 10_000_000_000 | |
| >>> ten_billion | |
| 10000000000 | |
| """ In output formatting, you can insert thousands separators: """ | |
| >>> f"{ten_billion:,}" | |
| '10,000,000,000' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment