related lists mean value (golfed)

Michael Rudolf spamfresser at
Tue Mar 9 16:00:00 CET 2010

Am 09.03.2010 13:02, schrieb Peter Otten:
>>>> [sum(a for a,b in zip(x,y) if b==c)/y.count(c)for c in y]
> [1.5, 1.5, 8.0, 4.0, 4.0, 4.0]
> Peter

... pwned.
Should be the fastest and shortest way to do it.

I tried to do something like this, but my brain hurt while trying to 
visualize list comprehension evaluation orders ;)


More information about the Python-list mailing list