Function Details: max

Description


Returns the largest item in an iterable or the largest of two or more arguments.


Extended Description


The max() function returns the largest item in an iterable or the largest of two or more arguments. It can be used with many different types, including numbers, strings, and custom objects. The optional 'key' argument specifies a function of one argument that is used to extract a comparison key from each element. The 'default' argument is returned if the iterable is empty.


Read More about max from Python Documentation

Function Signature


max(*args, key: Optional[Callable] = None, default: Optional[Any] = None) -> Any

Module: builtins

Parameters



Parameter List


  • *args: Any
  • key: Optional[Callable]
  • default: Optional[Any]

Return


Returns the maximum value from the given arguments or iterable.


Return Type


Any

Output

Explanation

These examples show how to use max() with direct arguments, a list, and a range object.