def formatnumber(n):
 parts = list(str(n))
 for i in range((len(parts) - 3), 0, (-3)):
  parts.insert(i, ',')
 return ''.join(parts)

def formatnumber ( n ) : parts = list ( str ( n ) ) for i in range ( ( len ( parts ) - 3 ) , 0 , ( - 3 ) ) : parts . insert ( i , ',' ) return '' . join ( parts )
format a number with beautiful commas .