Finding the maximum value in a list in Python can be done using the max()
function. Here are two examples:
Example 1:
numbers = [10, 5, 20, 15, 25] maximum = max(numbers) print(f"The maximum value is: {maximum}")
Output:
The maximum value is: 25
Example 2:
temperatures = [-2, 0, 5, -10, 3] maximum = max(temperatures) print(f"The maximum value is: {maximum}")
Output:
The maximum value is: 5