Getting at an item in a list of tupples

Tim Daneliuk tundra at tundraware.com
Wed Dec 12 02:50:04 CET 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