Find the maximum of a list of numbers in python
Here you will get an example to write a Python program find the maximum of a list of numbers.
Example to write a python program find the maximum of a list of numbers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | def find_maximum(numbers): if not numbers: raise Val_Error("List is empty.") max_num = numbers[0] for num in numbers: if num > max_num: max_num = num return max_num number_list = [4, 52, 39, 21, 15] max_number = find_maximum(number_list) print("Maximum number in the list:", max_number) |
Output
Maximum number in the list: 52
Check out our other Python programming examples