THE WORLD'S LARGEST WEB DEVELOPER SITE

Python min() Function

❮ Built-in Functions


Example

Return the lowest number:

x = min(5, 10)
Run example »

Definition and Usage

The min() function returns the item with the lowest value, or the item with the lowest value in an iterable.

If the values are strings, an alphabetically comparison is done.


Syntax

min(n1, n2, n3, ...)
Or:
min(iterable)

Parameter Values

Parameter Description
n1, n2, n3, ... One or more items to compare
Or:
Parameter Description
iterable An iterable, with one or more items to compare

More Examples

Example

Return the name with the lowest value, ordered alphabetically:

x = min("Mike", "John", "Vicky")
Run example »

Example

Return the item in a tuple with the lowest value:

a = (1, 5, 3, 9)
x = min(a)
Run example »

Related Pages

The max() function, to return the highest value.


❮ Built-in Functions