Trying to access and print specific indices of an array using a list of the required index numbers

48 Views Asked by At

I have an array of shape (8790,8) so a large list of information. I created a filter so I can access specific indices of this array. For example - my list is something like (79,2345,4544,6789,6790). I want to use this list to print the full corresponding indices in my original array. I tried this....

For i in finalList:
    if origArray[i][6] == choice:
        outputList.append(i)
        print(outputList)

I get TypeError: 'int' object not iterable.

1

There are 1 best solutions below

1
AudioBubble On BEST ANSWER

the problem must be the declaration of the variable finalList This works fine

>>> finalList = (79,2345,4544,6789,6790)
>>> for i in finalList:
...   print(i)
...
79
2345
4544
6789
6790