can some one help me with my code. thanks

Tim Chase python.list at tim.thechases.com
Fri Jan 20 15:17:47 EST 2012


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






More information about the Python-list mailing list