Min

Let’s look at how to use the reducing function, "min", on iterables.

We'll cover the following...

min function

min accepts an iterable and returns the minimum value from the iterable. For example:

Press + to interact
a = [2, 5, 7, 1]
print(min(a)) # 1

The iterable can contain items of any type, provided they can be compared with each other. For example, it can contain strings or lists, which will be compared in a standard way. Here is an example with lists:

Press + to interact
a = [[1, 2, 3], [1, 1, 5], [6, 7, 8], [1, 1, 5]]
print(min(a)) # [1, 1, 5]

Lists are compared ...