A restaurant recorded the ages of customers on two separate days. You are going to write a program to find the
maximum age of a customer.
What is the missing line of code?
customerAges = [13, 3, 11, 24, 35, 25, 15, 18, 1]
maximum = customerAges[0]
for item in customerAges:
maximum = item
print("Maximum value:",maximum)

See Answers (1)

Suggested Answer

customerAges = [13, 3, 11, 24, 35, 25, 15, 18, 1]maximum = customerAges[0]for item in customerAges:    if(item>=int(maximum)):        maximum=item    else:        continueprint("Maximum value:",maximum)If you assign the item value to the maximum value without compare them, then you should get the input which is 1. Because in the for loop, the program just putting the item value at current index to the maximum value whether it's equal or greater than the current maximum value. In the end of the loop, maximum variable's value will be 1. (Last index of the list)

Related Question in Computers and Technology