Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95803
| Path | csiph.com!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.055 |
| X-Spam-Evidence | '*H*': 0.89; '*S*': 0.00; 'builtin': 0.07; 'subject:python': 0.14; 'looping': 0.16; 'storing': 0.16; 'wrote:': 0.16; '2015': 0.20; 'aug': 0.20; '31,': 0.22; 'function:': 0.22; 'please?': 0.22; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'mon,': 0.24; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; 'print': 0.30; 'anyone': 0.32; 'url:python': 0.33; 'list': 0.34; 'received:google.com': 0.35; 'should': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'sum': 0.69; 'url:4': 0.70; 'to:name:python': 0.84; 'url:functions': 0.84 |
| 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 :content-type; bh=wxP7Ckp/gltk62fBN4FIGFz96fppAJMPjqFMH5HKAJ0=; b=gkI5yXE6eQh4xPdQ8jEihOJd290o9DrMIKufKwICyHbJAADIrUKURy50MzieZ7Dgg6 eZ5/cZLvf+N0H/50fyUzXIIddK/c1xkKnto0UtiPWCkRDlA2HxtCjxrr6l7oh4Et4ITJ /4oa+eQveZv/f0SLGN23G7+HQiQ/vIImYwYUFBNOA9yUuP2Rxy9FovAsmPIxCyswUNXZ AOlsnHSu5s7maf7EY6xktEO2Noi3ecWbf8V168tnwncjlRMKbhjGyGrceJAOAeRlZmim 9/Bp4T2Jxwcl+tElzsyhCznYVVXepamCud9OWMmT6TNNT3ikOQCeFR7+HEdGU3tjGHsV VEHw== |
| X-Received | by 10.13.204.68 with SMTP id o65mr24698586ywd.108.1441064114458; Mon, 31 Aug 2015 16:35:14 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <2b0f07c4-cda8-4bf9-9ef3-b80cccec81a4@googlegroups.com> |
| References | <2b0f07c4-cda8-4bf9-9ef3-b80cccec81a4@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 31 Aug 2015 17:34:35 -0600 |
| Subject | Re: Hi am new to python |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.23.1441064117.23514.python-list@python.org> (permalink) |
| Lines | 12 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1441064117 news.xs4all.nl 23860 [2001:888:2000:d::a6]:53786 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:95803 |
Show key headers only | View raw
On Mon, Aug 31, 2015 at 5:27 PM, Chubasco Diranga <alpharulz@gmail.com> wrote: > Can anyone please help me with the following please? > > My question is in a while loop; how do l sum all the numbers in the given list (list_a)? > > list_a = [8, 5, 2, 4] > sum_a = 0 # for storing the sum of list_a > i = 0 # for looping through the list_a# Use a while loop to sum all numbers in list_a# If you store the sums into sum_a > print(sum_a) # should print 19 You don't need a loop at all. Take a look at the builtin sum function: https://docs.python.org/3.4/library/functions.html#sum
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Hi am new to python Chubasco Diranga <alpharulz@gmail.com> - 2015-08-31 16:27 -0700 Re: Hi am new to python Ian Kelly <ian.g.kelly@gmail.com> - 2015-08-31 17:34 -0600 Re: Hi am new to python Emile van Sebille <emile@fenx.com> - 2015-08-31 16:36 -0700 Re: Hi am new to python Chris Angelico <rosuav@gmail.com> - 2015-09-01 10:01 +1000 Re: Hi am new to python Ben Finney <ben+python@benfinney.id.au> - 2015-09-01 10:22 +1000
csiph-web