![Python-courses-python-exercises-python-students-online-courses](https://1.bp.blogspot.com/-T3BongcoJFo/X4CftQxVL8I/AAAAAAAAB5U/Lf59WgNyhGo2FdogKqxv0PIy_Ef7XDPdgCLcBGAsYHQ/s0/my-python-courses-python-exercises-with-solutions.png)
Exercise 20
Write a Python algorithm which returns the maximum of the list without using any predefined function in Python.
Solution
def maximumList (L):
# initialization of the list maximum
maxList = L [0]
for x in L:
if maxList < x:
maxList = x
return maxList
#Example
L = [15, 31, 12, 7, 19, 23, 29]
print ("The maximum of list L is:", maximumList (L))
# The output is: the maximum of the list L is: 31
Younes Derfoufi
my-courses.net
my-courses.net