Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19169

Re: can some one help me with my code. thanks

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; ':-)': 0.06; 'terry': 0.07; 'def': 0.13; 'cc:addr:python-list': 0.15; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'cc:no real name:2**0': 0.21; 'subject:help': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.25; 'cc:addr:python.org': 0.29; 'subject:some': 0.30; 'header :User-Agent:1': 0.33; 'subject:can': 0.37; 'event': 0.38; 'subject:with': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'worth': 0.61; 'total': 0.61; 'happen': 0.61; 'subject:. ': 0.64; 'subject:one': 0.77; 'noting': 0.84; 'num': 0.84; 'subject:thanks': 0.84; '0.0': 0.91
Date Fri, 20 Jan 2012 14:17:47 -0600
From Tim Chase <python.list@tim.thechases.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16
MIME-Version 1.0
To Terry Reedy <tjreedy@udel.edu>
Subject Re: can some one help me with my code. thanks
References <feda1516-e842-4456-bbfb-2b9cdbe84e0f@u2g2000vbe.googlegroups.com> <jfcgap$8j4$1@dough.gmane.org>
In-Reply-To <jfcgap$8j4$1@dough.gmane.org>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Source
X-Source-Args
X-Source-Dir
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4897.1327094021.27778.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1327094021 news.xs4all.nl 6851 [2001:888:2000:d::a6]:51949
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19169

Show key headers only | View raw


On 01/20/12 13:46, Terry Reedy wrote:
> def average(bin):
>       num=[]
>       total = 0.0
>       count=0
>       for number in bin:
>           if number!='end':
>               total += float(number)
>               count+=1
>           else:
>               num.append(total/count)
>               total = 0.0
>               count= 0
>       return num

print(average(['end']))

ka-blooie! :-)

would be worth noting what should happen in the event of an empty 
bin.

-tkc


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

can some one help me with my code. thanks Tamanna Sultana <tamannas.rahman@gmail.com> - 2012-01-20 10:49 -0800
  Re: can some one help me with my code. thanks Terry Reedy <tjreedy@udel.edu> - 2012-01-20 14:46 -0500
  Re: can some one help me with my code. thanks Tim Chase <python.list@tim.thechases.com> - 2012-01-20 14:17 -0600
  Re: can some one help me with my code. thanks Terry Reedy <tjreedy@udel.edu> - 2012-01-20 16:26 -0500
    Re: can some one help me with my code. thanks Jon Clements <joncle@googlemail.com> - 2012-01-20 17:30 -0800
  Re: can some one help me with my code. thanks Rick Johnson <rantingrickjohnson@gmail.com> - 2012-01-20 16:21 -0800
    Re: can some one help me with my code. thanks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-21 02:23 +0000
      Re: can some one help me with my code. thanks Chris Angelico <rosuav@gmail.com> - 2012-01-21 15:03 +1100
        Re: can some one help me with my code. thanks Tamanna Sultana <tamannas.rahman@gmail.com> - 2012-01-23 05:47 -0800
      Re: can some one help me with my code. thanks Tamanna Sultana <tamannas.rahman@gmail.com> - 2012-01-23 05:47 -0800

csiph-web