On Sat, Jun 4, 2022 at 9:07 PM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> On 5/06/22 10:07 am, dn wrote: > > On 05/06/2022 09.50, Chris Angelico wrote: > >>>>> min(enumerate(l), key=lambda x: x[1]) > >> (0, 1.618033) > > > > But, but, but which of the above characters is an 'el' and which a > 'one'??? > > (please have pity on us old f...s and the visually-challenged!) > > > > ell = l > one = 1 > min(enumerate(ell), key=lambda x: x[one]) > > Hope that clears it up!!!!!11!one!ell > I'm kind of partial to: min((value, index) for (index, value) in enumerate(list_)) It'll return a single 2-tuple where the value of interest is at position 0. In the event of a tie, it should give you the first such value encountered. -- https://mail.python.org/mailman/listinfo/python-list