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