returning index of minimum in a list of lists

tactics40 at gmail.com tactics40 at gmail.com
Wed Jun 21 11:23:34 EDT 2006


JJLaRocque at gmail.com wrote:
> 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 your example, you returned 2, 4. Did you mean 1, 3?

mylist[1][3] is the way you would access the "1" in your list of lists.

I don't think this task would have a built in function, but you could
write one in less than 4 lines of code easily.




More information about the Python-list mailing list