It is possible to traverse a list using the for
loop, and you have to specify what to do on each iteration of the loop.
- Please use the
for
loop function to get the minimum value from the list and print it in the console.
-
Declare an auxiliary global variable.
-
Set its value to the first element on the list.
-
Every time you loop, compare its value to the next element's value, if it's smaller, update the auxiliary variable's value to the element's value.
-
Outside the loop, after the loop is finished, print the auxiliary variable's value.
23