On 3/6/2013 7:07 PM, Chris Rebert wrote:
On Wed, Mar 6, 2013 at 3:39 PM, eli m <techgeek...@gmail.com> wrote:
I have a python program that accepts input and calculates the factorial of that 
number, and i want to know if i can make it so commas get inserted in the 
number.
For example: instead of 1000 it would say 1,000

Use the "," (i.e. comma) format() specifier directive. See
http://docs.python.org/2/library/string.html#format-specification-mini-language
See also: http://www.python.org/dev/peps/pep-0378/

>>> format(12345234434, ',d')
'12,345,234,434'
>>> '{:,d}'.format(333333333333)
'333,333,333,333'

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to