Skip to content

Instantly share code, notes, and snippets.

@polotek
Created May 6, 2015 00:20
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 polotek/19019310f765a1dc24c9 to your computer and use it in GitHub Desktop.
Save polotek/19019310f765a1dc24c9 to your computer and use it in GitHub Desktop.
def format_number(num):
numstr = str(num)
chunks = []
while numstr:
numstr, newchunk = numstr[:-3], numstr[-3:]
chunks.append(newchunk)
return ','.join(chunks[::-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment