What is min() in Python?

The min() method in Python returns the smallest value from an iterable object.

Syntax

This method is declared as follows:

The syntax of min() method in Python

Parameter

Only one parameter is required in the min() method. This parameter can be a list or tuple of integers, floating-point numbers, strings, or characters.

Return value

The return value of this method depends upon the parameter. If an iterable object of integers is passed into min(), it returns the smallest integer.

In the case of a list of strings or characters as the argument of the min() method, the lowest value is returned.

Example

For example, in the first two calls, min() returns the smallest number from the list. From the list of strings, it returns “abcf” because this sequence is the smallest, alphabetically.

# List of integers
int_list = [2, 7, 3, 9]
print(min(int_list))
# List of floating point numbers
float_list = [12.1, 7.2, 3.5, 9.9]
print(min(float_list))
# List of strings
str_list = ["xyz", "abcf", "abd", "ghij"]
print(min(str_list))

Free Resources