Answers for "getting index of array in loop in python"

4

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
0

get index of list item in loop

ints = [1,2,3,4,'5','6']

for idx, val in enumerate(ints):
    print(idx, val)
#Output
0 1
1 2
2 3
3 4
4 '5'
5 '6'
Posted by: Guest on May-03-2021

Code answers related to "getting index of array in loop in python"

Python Answers by Framework

Browse Popular Code Answers by Language