| 1 | initial version |
You could define a pretty-printing function:
def print3(n):
# add commas every third digit from the right
s = ''
for k, d in enumerate(str(n)[::-1]):
if k%3 == 0: s += ','
s += d
print s[:0:-1]
and use it to print your numbers:
sage: print3(100)
100
sage: print3(1000)
1,000
sage: print3(10000)
10,000
sage: print3(100000000000)
100,000,000,000
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.