Home > Article > Backend Development > How to find the maximum value of a set of numbers in python?
#How to find the maximum value of a set of numbers in python?
Python method to find the maximum value of a set of numbers:
First define a set of numbers and variable a, and assign [a=list(0)] ; Then use range loop to query. If the number is greater than [list=(0)], then pass the value to a and output it.
def max2(list): a = list[0] for prime in range (1,len(list)): if list[prime] > list[0]: a = list[prime] return a print(max2([1,5,2,3,6,8,10,15]))
Recommended tutorial: "python video tutorial"
The above is the detailed content of How to find the maximum value of a set of numbers in python?. For more information, please follow other related articles on the PHP Chinese website!