min() and max()

Built-in functions that return the smallest or largest item of an iterable, or of several arguments; sum adds them up.

In more detail

min and max accept key= like sorted, so max(words, key=len) finds the longest word. sum has no key; use a generator expression instead, as in sum(len(w) for w in words).

Example

max(["fig", "banana"], key=len)

Related terms

Taught in

References

Certification courses