Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'python': 0.09; 'accepts': 0.09; 'calculates': 0.09; 'directive.': 0.09; 'inserted': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:number': 0.09; 'terry': 0.09; 'url:peps': 0.09; '","': 0.16; '1,000': 0.16; 'also:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'specifier': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'url:dev': 0.17; 'jan': 0.18; '>>>': 0.18; 'input': 0.18; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; "skip:' 10": 0.30; 'url:python': 0.32; "skip:' 20": 0.32; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'subject:?': 0.35; 'received:org': 0.36; 'url:org': 0.36; '(i.e.': 0.36; 'url:library': 0.36; 'subject:: ': 0.38; 'url:docs': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; '2013': 0.84; 'received:fios.verizon.net': 0.84; 'url:string': 0.84; 'eli': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Insert comma in number? Date: Wed, 06 Mar 2013 20:28:56 -0500 References: <9c8df3b5-510a-4d00-a3ff-0c59799dcded@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362619758 news.xs4all.nl 6884 [2001:888:2000:d::a6]:33821 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40683 On 3/6/2013 7:07 PM, Chris Rebert wrote: > On Wed, Mar 6, 2013 at 3:39 PM, eli m 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