max value in list

Duncan Booth me at privacy.net
Wed May 12 16:54:58 EDT 2004


"Terry Reedy" <tjreedy at udel.edu> wrote in 
news:mailman.462.1084374987.25742.python-list at python.org:

> Sidestepping 'best' which may depend on context, a general 'good' way is
> 
>>>> lists = [2,3,4],[1,2,3],[4,7]
>>>> max([max(l) for l in lists])
> 7
> 

Without any claims to better or worse, here is another option:

>>> l = [2,3,4],[1,2,3],[4,7]
>>> l
([2, 3, 4], [1, 2, 3], [4, 7])
>>> max(itertools.chain(*l))
7
>>> 



More information about the Python-list mailing list