count = 0 #Set the variable count to zero before the loop starts for i in [3, 41, 12, 9, 74, 15]: # Our iteration variable, itervar, controls the loop and cause the loop body to be executed once for each values in list. count = count + 1 #In the body of the loop, we add 1 to the current value of count print('Count: ', count) # Once the loop completes, the value of count is the total number of items
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter