Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19169
| Date | 2012-01-20 14:17 -0600 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4897.1327094021.27778.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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