On Fri, 23 Apr 2010 00:07:18 +1000
Xavier Ho <cont...@xavierho.com> wrote:
> > print (sorted (l, reverse=True)[:k])
> 
> You don't really need to reverse sort there:

True but...

> >>> numbers = [1, 4, 5, 3, 7, 8]
> >>> sorted(numbers)[3:]
> [5, 7, 8]

Now try returning the top two or four numbers.

-- 
D'Arcy J.M. Cain <da...@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to