The first part is simple:
temp = "8,741,291".replace(',', '') n = int(temp) * 2
I thought returning commas was a bit more difficult, but it really is not!
If you are using the latest version of Python, you can use the new .format() line method as follows:
s = "{0:,}".format(n)
If you are using Python later than 2.6, you can omit 0 from the curly braces in this example. (Alas, I have to use Cygwin, and, alas, it only gives 2.6, so I use 0 for input.)
The specification mini-language for the .format() method is here:
http://docs.python.org/library/string.html#formatstrings
@ user1474424 explained the function locale.format() , which is cool; I did not know about it. I checked the documents; It has been around since Python 1.5!
http://docs.python.org/library/locale.html
source share