Okay, let's get started.
Finding the smallest or largest element in a data structure is such a common task that Python gives us two built-in utility functions:
max(). Both functions work with any data structure that can be iterated over with a
for loop: lists, sets, tuples, and even strings.
Suppose we have a list that represents the number of customer requests processed per day:
requests_processed = [12, 18, 15, 23, 24, 8, 0, 18, 14, 13]
To find the maximum number of requests processed, we use:
And to find the minimum number:
As you can see,
max() are extremely easy to use.