Thousand Seperator

Paul Rubin http
Fri Mar 14 18:18:32 CET 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