Python min() Function

Example

Return the smallest number:

x = min(5, 10)

Run Example

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")

Run Example

Example

Return the smallest item in the tuple:

a = (1, 5, 3, 9, 7)
x = min(a)

Run Example

Related Pages

Reference Manual:max() Function(Return Maximum Value)