maximum element?
JCM
joshway_without_spam at myway.com
Thu Mar 4 16:30:06 EST 2004
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... :)
reduce(lambda x, y: (x, y)[x < y], list)
Sorry, couldn't resist.
More information about the Python-list
mailing list