this loop iterates over the number of code example
Example 1: python return iteration number of for loop
for iteration, item in enumerate(iteratable_object):
print(iteration)
[iteration for iteration, item in enumerate(iteratable_object)]
your_list = ["a", "b", "c", "d"]
for iteration,item in enumerate(your_list):
(iteration, item)
--> (0, 'a')
(1, 'b')
(2, 'c')
(3, 'd')
[iteration for iteration, item in enumerate(your_list)]
--> [0, 1, 2, 3]
Example 2: javascript for loop 5 times
for (let step = 0; step < 5; step++) {
// Runs 5 times, with values of step 0 through 4.
console.log('Walking east one step');
}