Python min() Function
Definition and Usage
The min() function returns the smallest item, or the smallest item in the iterable.
If the value is a string, it is compared in alphabetical order.
Syntax
min(n1, n2, n3, ...)
Or:
min(iterable)
Parameter Value
Parameter | Description |
---|---|
n1, n2, n3, ... | One or more items to be compared. |
Or:
Parameter | Description |
---|---|
iterable | An iterable containing one or more items to be compared. |
More Examples
Example
Return the smallest name in alphabetical order:
x = min("Steve", "Bill", "Elon")
Example
Return the smallest item in the tuple:
a = (1, 5, 3, 9, 7) x = min(a)
Related Pages
Reference Manual:max() Function(Return Maximum Value)