D
D
Dauren S2020-09-16 10:49:39
Python
Dauren S, 2020-09-16 10:49:39

Walk through a multidimensional array again?

There is an array comp
How to go through it so that the counter shows the index 0 1 2 0 1 2?

comp=[1,2],[3,4],[5,6]
for i,data in enumerate(comp):
  for k in comp[i]:
    print(i)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-09-16
@dauren101

for i in range(len(comp[0])):
  for j in range(len(comp)):
    print(j)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question