Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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.097 X-Spam-Evidence: '*H*': 0.82; '*S*': 0.02; 'subject:help': 0.08; 'seemed': 0.09; 'cc:addr:python-list': 0.11; 'calculator': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'skip:" 30': 0.26; 'post': 0.26; 'code:': 0.26; 'header:In-Reply- To:1': 0.27; 'tried': 0.27; 'appreciated.': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'anyone': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'should': 0.36; 'skip:. 20': 0.38; 'needed': 0.38; 'making': 0.63; 'subject:Need': 0.64; 'to:addr:gmail.com': 0.65; 'either:': 0.91; 'hate': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=CCHAP7X3FVN+KKCMYnmvIQY4hx/SdhouMydOIEolXz8=; b=SbDdwE95+8Iez2IiwMVPfd2eTZueA4CIfW8EHCcCzDNSyWMunG9Me6vpkbFovK1jmo V/NtA9vKMMitw68Mf6Xa4MNhYGgoP+Pk5MdXWJxspMZpIds6LUqi9tMWY0bQpBDbxxNK B5oWLSyX5E4Y7m7IwumZHqoUGMQn5UQxSR1HG+naAdCv3kF6vFZXPJx55SUEUrASS48k VJDugaTlCuAqIwaNX8bcoyGtp0JUGBFX/NNceT3tT0uVddicedTWTFML6Sc+ZIccVnTt 8srbKz9IpbqMTXWNsQtjtnEePTn/ZmIE035ZzQl3w1Ox0rsZczv0epdqSI2F2cD1WRO5 ZibA== X-Received: by 10.152.45.65 with SMTP id k1mr2774138lam.78.1372284885163; Wed, 26 Jun 2013 15:14:45 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <55bb3a29-7c8a-402c-8fb5-d12b5ee6330b@googlegroups.com> References: <55bb3a29-7c8a-402c-8fb5-d12b5ee6330b@googlegroups.com> From: Joshua Landau Date: Wed, 26 Jun 2013 23:14:05 +0100 Subject: Re: Need help removing trailing zeros To: bandcamp57@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372284893 news.xs4all.nl 15878 [2001:888:2000:d::a6]:37657 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49281 On 26 June 2013 23:02, wrote: > Hello, i'm making a calculator and I want to be able to use decimals but = I don't like it when it comes out as ex.12.0 when it should be 12. I tried = using .rstrip("0".rstrip(".") but that never seemed to work. If anyone has = a solution please let me know, all help is greatly appreciated. > > Code: Was that really necessary? All you needed to give use was "print(1.0)"; why post so much? Either: "{:g}".format(1.0) or, if you hate scientific notation: "{:f}".format(1.0).rstrip(".0")