Home > Article > Backend Development > How to find the maximum and minimum value of a list in python
You can use the built-in max() and min() functions to find the maximum and minimum values of a list.
For example, suppose there is a list nums:
nums = [5, 2, 9, 1, 7]
To find the maximum value, you can use the max() function:
max_value = max(nums) print(max_value)# Output: 9
To find the minimum value, you can use the min() function:
min_value = min(nums) print(min_value)# Output: 1
This way you can find the maximum and minimum values in the list.
The above is the detailed content of How to find the maximum and minimum value of a list in python. For more information, please follow other related articles on the PHP Chinese website!