Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40683
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Insert comma in number? |
| Date | 2013-03-06 20:28 -0500 |
| References | <9c8df3b5-510a-4d00-a3ff-0c59799dcded@googlegroups.com> <CAMZYqRQioi8FcMEyQoQMfMK-=MmHNEQcPvHUS6Yc6_QHpeTqgA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2969.1362619758.2939.python-list@python.org> (permalink) |
On 3/6/2013 7:07 PM, Chris Rebert wrote:
> On Wed, Mar 6, 2013 at 3:39 PM, eli m <techgeek201@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Insert comma in number? eli m <techgeek201@gmail.com> - 2013-03-06 15:39 -0800 Re: Insert comma in number? ian douglas <iandouglas736@gmail.com> - 2013-03-06 15:51 -0800 Re: Insert comma in number? Chris Rebert <clp2@rebertia.com> - 2013-03-06 16:07 -0800 Re: Insert comma in number? Terry Reedy <tjreedy@udel.edu> - 2013-03-06 20:28 -0500 Re: Insert comma in number? Peter Otten <__peter__@web.de> - 2013-03-07 08:55 +0100 Re: Insert comma in number? Paul Volkov <capt-obvious@yandex.ru> - 2013-03-07 12:30 +0400 Re: Insert comma in number? Peter Otten <__peter__@web.de> - 2013-03-07 09:58 +0100
csiph-web