Write a PYTHON function called myMax which accepts a LIST of numbers and returns the maximum number in the list. Do NOT use Python’s built-in function max.
Example: result = myMax([-999000, -1000000, -2000000]); print(result) #output is -999000
Example: result = myMax([1000000, 1000001, 1000002]); print(result) #output is 1000002
Refer to the function below which returns the maximum element from
a list
Source code:
def my_max(lst):
max_val = lst[0]
for item in lst:
if item > max_val:
max_val = item
return max_val
result = my_max([-999000, -1000000, -2000000]); print(result)
Output screenshot:
Get Answers For Free
Most questions answered within 1 hours.