returning index of minimum in a list of lists

Maric Michaud maric at aristote.info
Wed Jun 21 11:31:41 EDT 2006


Le Mercredi 21 Juin 2006 16:54, JJLaRocque at gmail.com a écrit :
> Hi all,
> Is there a simple python function to return the list index of the
> minimum entry in a list of lists?
> ie, for   [[3,3,3,3], [3,3,3,1], [3,3,3,3]]  to return 2,4.
> Or, same question but just for a list of numbers, not a list of lists.
> Thanks,
> Josh


In [7]: min([3, 3, 1, 3])
Out[7]: 1

In [8]: min(min(e) for e in  [ [3, 3], [3, 3, 1, 3], [3, 3, 3] ])
Out[8]: 1

regards,

-- 
_____________

Maric Michaud
_____________

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097



More information about the Python-list mailing list