iteration we set the variable count to zero before the loop startsthen we write for loop to run through the list of numbers our iteration variable is named itervar and while we do not use itervar in the loopit does control the loop and cause the loop body to be executed once for each of the values in the list in the body of the loopwe add to the current value of count for each of the values in the list while the loop is executingthe value of count is the number of values we have seen "so faronce the loop completesthe value of count is the total number of items the total number "falls in our lapat the end of the loop we construct the loop so that we have what we want when the loop finishes another similar loop that computes the total of set of numbers is as followstotal for itervar in [ ]total total itervar print('total'totalin this loop we do use the iteration variable instead of simply adding one to the count as in the previous loopwe add the actual number ( etc to the running total during each loop iteration if you think about the variable totalit contains the "running total of the values so farso before the loop starts total is zero because we have not yet seen any valuesduring the loop total is the running totaland at the end of the loop total is the overall total of all the values in the list as the loop executestotal accumulates the sum of the elementsa variable used this way is sometimes called an accumulator neither the counting loop nor the summing loop are particularly useful in practice because there are built-in functions len(and sum(that compute the number of items in list and the total of the items in the list respectively maximum and minimum loops to find the largest value in list or sequencewe construct the following looplargest none print('before:'largestfor itervar in [ ]if largest is none or itervar largest largest itervar print('loop:'itervarlargestprint('largest:'largestwhen the program executesthe output is as followsbeforenone loop