Skip to content

Instantly share code, notes, and snippets.

@myano
Created May 5, 2016 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myano/67c81f691e2b0eccdb868738041262ad to your computer and use it in GitHub Desktop.
Save myano/67c81f691e2b0eccdb868738041262ad to your computer and use it in GitHub Desktop.
Format a really long number with commas
def formatnumber(n):
"""Format a number with beautiful commas."""
parts = list(str(n))
for i in range((len(parts) - 3), 0, -3):
parts.insert(i, ',')
return ''.join(parts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment