maximum element?
David M. Cooke
cookedm+news at physics.mcmaster.ca
Thu Mar 4 16:11:07 EST 2004
At some point, Ivan Voras <ivoras at __geri.cc.fer.hr> wrote:
> What is the 'most pythonic' way of searching the largest element in a
> list/tuple?
>
> My 'standard' idea is:
>
> max = list[0] # or -infinity, or whatever...
> for i in list:
> if i > max:
> max = i
>
> While this is ok, I somehow 'feel' there could be a more concise
> solution... :)
max(list)
--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
More information about the Python-list
mailing list