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



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to