Thousand Seperator

Paul Rubin http
Fri Mar 14 13:18:32 EDT 2008


ewanfisher at gmail.com writes:
> 100 -> 100
> 1000 -> 1,000
> 1000000 -> 1,000,000
> -1000 -> -1,000

def sep(n):
  if n<0: return '-' + sep(-n)
  if n<1000: return str(n)
  return '%s,%03d' % (sep(n//1000), n%1000)



More information about the Python-list mailing list