Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:python': 0.14; 'looping': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'storing': 0.16; 'wrote:': 0.16; 'language': 0.19; 'please?': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'question': 0.27; 'this.': 0.28; 'tutorial': 0.29; 'print': 0.30; 'anyone': 0.32; 'url:python': 0.33; 'list': 0.34; 'should': 0.36; 'url:org': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:org': 0.37; 'to:addr:python.org': 0.40; 'easy': 0.60; 'url:3': 0.60; 'charset:windows-1252': 0.62; 'sum': 0.69; 'yourself': 0.73; 'received:12': 0.81; 'url:tutorial': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Emile van Sebille Subject: Re: Hi am new to python Date: Mon, 31 Aug 2015 16:36:45 -0700 References: <2b0f07c4-cda8-4bf9-9ef3-b80cccec81a4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: www.westernstatesglass.com User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 In-Reply-To: <2b0f07c4-cda8-4bf9-9ef3-b80cccec81a4@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441064314 news.xs4all.nl 23764 [2001:888:2000:d::a6]:56472 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3151 X-Received-Body-CRC: 1598201185 Xref: csiph.com comp.lang.python:95804 On 8/31/2015 4:27 PM, Chubasco Diranga 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 should familiarize yourself with the language -- there's a really easy answer to this. Review the tutorial at https://docs.python.org/3/tutorial/ Emile