Answers for "python iterate over index"

30

python3 iterate through indexes

items=['baseball','basketball','football']
for index, item in enumerate(items):
    print(index, item)
Posted by: Guest on May-07-2020
18

python access index in for loop

for index, item in enumerate(items):
    print(index, item)

#if you want to start from 1 instead of 0
for count, item in enumerate(items, start=1):
    print(count, item)
Posted by: Guest on July-03-2020
5

python for loop array index

colors = ["red", "green", "blue", "purple"]
i = 0
while i < len(colors):
    print(colors[i])
    i += 1
Posted by: Guest on August-29-2020

Code answers related to "python iterate over index"

Python Answers by Framework

Browse Popular Code Answers by Language