Built-in Functions
min()
Find the smallest item in an iterable.
min(iterable, *, key=None, default=...)
min() returns the smallest item in an iterable or the smallest of two or more arguments.
Parameters
| Name | Description |
|---|---|
| iterable | Items to compare. |
| key | Optional function used to choose how items are compared. |
| default | Optional value returned for an empty iterable. |
Returns
The smallest item.
Try it
Run it and change it
temperatures = [18, 12, 16] print(min(temperatures))
Worth knowing
- Key function:
min(words, key=len)finds the shortest string in a collection.