Solution Review: Find Maximum in a List
This lesson will explain how to find the maximum number in a list using for loop.
We'll cover the following
Solution for Problem Statement1: Use for
loop
The problem statement 1 states that the task is to find the maximum number in the list. The straight forward solution to the problem is:
- Save the value of the first index.
- Use for loop to iterate over the list, then compare the saved value with each value in the list. If any value in the list is greater than the saved value, update the saved value.
This can be seen more clearly in the following illustration.
Get hands-on with 1200+ tech skills courses.