Aah!  A nested list comprehension.  I hadn't considered that. Thanks, your 
solution is both concise and easy to read. 

and, oops, you're right, I was thinking of median but saying mean. 

cheers
S

----- Original Message ----
From: Kent Johnson <[EMAIL PROTECTED]>

That is the median, not the mean. For this approach to work you have to 
sort dataDict.items(), in general dict keys and values are not in any 
obvious order. Fortunately it is easy to do this:
prods = [ key for key,val in sorted(dataDict.items()) for i in range(val) ]






__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to