import re

num = 123456789

print ','.join(re.findall("\d{3}", str(num)))

output:
123,456,789


----- Original Message -----
From: [EMAIL PROTECTED]
To: tutor@python.org
Date: Fri, 21 Mar 2008 21:49:18 -0700
Subject: [Tutor] Even More Converter!

It works perfectly, so I am sure my question will not be hard to answer.
When Python gives me the answer to my conversion, is there a way to create it 
so every 3 numbers a comma is inserted?
Such as: 1 mile is 5,280 feet. Instead of 1 mile is 5280 feet. Yes a simple 
thing, but something which I believe will make it look better.
Also is there a way to make this so I don't have to go through every 
individual line of code and add *insert comma* or something to it, simply 
at the top like how the Unit Menu is placed only once there, and yet 
applies to the whole document. Thank you
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to