Python max() built-in function
From the Python 3 documentation
Return the largest item in an iterable or the largest of two or more arguments.
Introduction
The max()
function can be used in two ways:
- With an iterable (like a list or tuple), it returns the largest item.
- With two or more arguments, it returns the largest of them.
Examples
Finding the max in an iterable:
numbers = [1, 2, 10, 40, 5]
print(max(numbers)) # Output: 40
letters = ('a', 'b', 'z')
print(max(letters)) # Output: 'z'
Finding the max of several arguments:
print(max(10, 20, 5)) # Output: 20