Bruno Desthuilliers wrote: > Steven Woody a écrit : >> In additional to max/min, is there something like average()? > > Not AFAIK, but it's really trivial > > def average(lst): > """ assume lst is a list of numerics """ > return sum(lst) / len(lst)
If you are using Python 2.x: >>> def average(lst): ... return sum(lst)/len(lst) ... >>> average([1,2]) 1 So you better throw in a float(...): >>> def average(lst): ... return sum(lst)/float(len(lst)) ... >>> average([1,2]) 1.5 Peter -- http://mail.python.org/mailman/listinfo/python-list