Skip to content

Instantly share code, notes, and snippets.

@kkroesch
Last active October 29, 2021 10:54
Show Gist options
  • Select an option

  • Save kkroesch/a0a1829b79888bc11e638df07f37b4fb to your computer and use it in GitHub Desktop.

Select an option

Save kkroesch/a0a1829b79888bc11e638df07f37b4fb to your computer and use it in GitHub Desktop.
Readable large numbers in Python
""" 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