Answer to Question #196889 in Python for Jack

Question #196889

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.


1
Expert's answer
2021-05-25T00:08:19-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS