Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83559
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'float': 0.07; 'modify': 0.07; 'string': 0.09; 'line:': 0.09; 'strings.': 0.09; 'subject:string': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; "','": 0.16; '4.4,': 0.16; 'wrote:': 0.18; 'split': 0.19; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'values': 0.27; 'header:In-Reply-To:1': 0.27; '----': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; "skip:' 10": 0.31; 'decimal': 0.31; 'subject:numbers': 0.31; 'url:python': 0.33; '-----': 0.33; 'subject:from': 0.34; 'subject:with': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'pm,': 0.38; 'url:mail': 0.40; 'how': 0.40; 'numbers': 0.61; 'total': 0.65; 'to:addr:gmail.com': 0.65; '2015': 0.84; 'joel': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Ql3zGmMqOjqA41s45cGVvvm8doD2IEUoFOOD6tT+c+8=; b=mrM39oyVRW9I3+zXhaXaes7edK433U45Sk8jevc1gQcPacUV59KOVI1gkUPXzcvYF/ ldDzdbHleeyuWVJG5RHvv93zxTojeFKmIClrGbDFv9CeEM18zePd9FUBcIPzxSC3c8mv 7HZaMm1jtxdt87JMR/40fpd3A9QuEujC8JmN1uBxUuSRP6+gXmuJmASekn+0tthG+tmh ZkRtNVkLMagLGipilZyVQ2lcTGj6784rk/BBXr6uiqHCMQ8ceotMkKcf6rT5PI8J41+a izb4mEFMAtjzSoSKVr3O0g57e68tvrV6dDhYWXn/qMkRqqVL1MYoXxqdmLY46RLSoAqy 13aA== |
| MIME-Version | 1.0 |
| X-Received | by 10.229.240.130 with SMTP id la2mr44099908qcb.9.1421006794866; Sun, 11 Jan 2015 12:06:34 -0800 (PST) |
| In-Reply-To | <7240a574-dfd7-46c3-80eb-0657b41894bb@googlegroups.com> |
| References | <7240a574-dfd7-46c3-80eb-0657b41894bb@googlegroups.com> |
| Date | Sun, 11 Jan 2015 15:06:34 -0500 |
| Subject | Re: extracting numbers with decimal places from a string |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| To | Store Makhzan <store0a@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | "python-list@python.org" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17591.1421006803.18130.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1421006803 news.xs4all.nl 2841 [2001:888:2000:d::a6]:38457 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83559 |
Show key headers only | View raw
On Sun, Jan 11, 2015 at 2:31 PM, Store Makhzan <store0a@gmail.com> wrote: > I have this script which can calculate the total of numbers given in a string > ---- script ----- > total = 0 > for c in '0123456789': > total += int(c) > print total > ---- script ----- > > How should I modify this script to find the total of if the numbers given in the string form have decimal places? That is, how do I need to modify this line: > ----- script ----- > for c in '1.32, 5.32, 4.4, 3.78': > ----- script ----- > to find the total of these given numbers. > -- > https://mail.python.org/mailman/listinfo/python-list split the string on ',' to get a list of strings. loop thru list using float(s), add float values -- Joel Goldstick http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
extracting numbers with decimal places from a string Store Makhzan <store0a@gmail.com> - 2015-01-11 11:31 -0800
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 15:06 -0500
Re: extracting numbers with decimal places from a string Store Makhzan <store0a@gmail.com> - 2015-01-11 12:26 -0800
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 16:42 -0500
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-11 23:20 +0100
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 17:54 -0500
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 00:12 +0100
Re: extracting numbers with decimal places from a string Joel Goldstick <joel.goldstick@gmail.com> - 2015-01-11 18:35 -0500
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 00:46 +0100
Re: extracting numbers with decimal places from a string Peter Otten <__peter__@web.de> - 2015-01-12 01:09 +0100
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 01:45 +0100
Re: extracting numbers with decimal places from a string Chris Angelico <rosuav@gmail.com> - 2015-01-12 11:17 +1100
Re: extracting numbers with decimal places from a string Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-12 11:45 +1100
Re: extracting numbers with decimal places from a string Grant Edwards <invalid@invalid.invalid> - 2015-01-11 23:06 +0000
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 00:07 +0100
Re: extracting numbers with decimal places from a string Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-12 00:04 +0000
Re: extracting numbers with decimal places from a string Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-12 02:00 +0100
Re: extracting numbers with decimal places from a string MRAB <python@mrabarnett.plus.com> - 2015-01-12 00:59 +0000
Re: extracting numbers with decimal places from a string Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-12 12:13 +1100
csiph-web