Home / Python / Reference / Built-in functions

Python min() function

Return the smallest item.

Syntax

min(iterable, *, key=None, default=...) / min(a, b, ...)

The mirror image of max, with the same key and default options.

Parameters

iterablethe items to compare
keya function that gives the value to compare
defaultreturned if the iterable is empty

Return value

the smallest item

Example

Code

print(min([3, 9, 2]))
print(min("python"))                    # smallest character
prices = {"tea": 3.0, "coffee": 4.5, "juice": 6.0}
print(min(prices, key=prices.get))      # the cheapest item's name
print(min([], default=None))

Output

2
h
tea
None

Related

Learn it step by step in the free lesson More Functions, with exercises that check your answers.