[Solved] extract the index from a value in an array [closed]


If I understood your question correctly, you want to get the all indexes where 8 is in right?

So 4 in your example is the answer you want to get?

This code will return you the indexes of all occurences of 8:

myTable = [ [1, 4, 1, 2],
            [2, 5, 3, 2],
            [0, 4, 4, 2],
            [3, 6, 5, 2],
            [7, 8, 6, 2],
            [11, 1, 7, 2],
            [10, 17, 7, 2] ]

print ([(i)
   for i, myValue in enumerate(myTable)
   if 8 in myValue])

2

solved extract the index from a value in an array [closed]