Getting at an item in a list of tupples

Tim Daneliuk tundra at tundraware.com
Tue Dec 11 20:50:04 EST 2001


Bob Greschke wrote:
> 
> Here's what I've got
> 
>    a = []
>    a.append((ints, floats, strings))
>    a.append((ints, floats, strings))
>    a.append((ints, floats, strings))
>    a.append((ints, floats, strings))
>    ...
> 
> I want to do something like
> 
>    print max(of all of the floats)
>    print min(of all of the floats)
> 
> In general, how do you get at the floats (or ints, or strings)?  We
> can see doing something with map() calling a function that returns the
> second item, but isn't there something a little simpler?
> 

How about:

print max([f for i, f, s in a])


-- 
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com



More information about the Python-list mailing list