Write a program that takes a list of integers as a parameter and returns the max element in the list without using the built-in ‘max()’ function.
def maxElement(list1):
max=list1[0]
for i in range(len(list1)):
if list1[i]>max:
max=list1[i]
return max
if __name__ == '__main__':
l=[23,45,67,78]
maximum=maxElement(l)
print("The maximum element is ",maximum)
Comments
Leave a comment