In this exercise, the function is passed three numbers as parameters and determines the maximum value. How can the function return the maximum value for a list of numbers?
Python includes a
max() function which does this task. If you pass the
max() function a list of numbers, it will return the largest number in the list as shown in this example. If the exercise function was re-written to accept a list of numbers as a parameter, it could just call
max() to find the largest value.
num = (100, 2, 5, 99, 24, 300, 88, 72) print(max(num)) #Output: 300