Chapters
Python114 chapters

ReferenceBuilt-in functions

min()

The smallest item, optionally judged by a key function.

Signature

min(iterable, key=None, default=...)

Parameters

NameMeans
iterableor several separate arguments
keycalled on each item to decide the ordering
defaultreturned when the iterable is empty

Returns

The item itself.

Example

Python
print(min([3, 1, 4]))
print(min(["apple", "fig"], key=len))

Output

1
fig

See also