Find the greatest number in a list of numbers

Chris Foster picture Chris Foster · Jun 22, 2010 · Viewed 290.8k times · Source

Is there any easy way or function to determine the greatest number in a python list? I could just code it, as I only have three numbers, however it would make the code a lot less redundant if I could tell the greatest with a built in function or something.

Answer

Jubal picture Jubal · Jun 22, 2010

What about max()

highest = max(1, 2, 3)  # or max([1, 2, 3]) for lists