Mean, median, and mode

Fredrik Lundh fredrik at pythonware.com
Mon Dec 6 23:04:17 CET 2004


Paul Rubin wrote:

> > > median = lambda x: x.sort() or x[len(x)//2]
>
> Yucch!!
>
> median = x.sorted()[len(x)//2]

that doesn't do the same thing, and doesn't work on pre-2.4 releases.

try again.

(learning how "or" and "and" works in Python doesn't hurt, either;
"value or value" is a very common idiom in Python code)

</F> 






More information about the Python-list mailing list