Say I have a value…
x = 5
and a numpy array of arrays which looks something like…
arr = [[1,2], [3,4], [5,6]]
how would I check the first index of each array (ie. 1, 3, 5) to see if they = x?
>Solution :
You may find any() function useful in this case. It takes a list as an argument, and returns True if any of their arguments evaluate to True (and False otherwise).
Here’s how you do
if any([i[0] == x for i in arr]):