Question: I have a 2D NumPy array that of shape (1500, 3712). I want to find the indices of the array that have values between -10 and -40. So far I have:

```py
for item in lon_array:
    for value in item:
        if value >= -40 and value <= -10:
            find_index = np.where(lon_array == value)
            index = np.asarray(find_index).T

```

Since it is a really big array, is there any way to make this faster?

Answer: 
Assuming your `lon_array` is a NumPy array you can use the following methods:

```py
find_index = np.where(np.logical_and(lon_array >= -40, lon_arr <= -10))
index =  np.asarray(find_index).T

```

Since `np.where` takes only one condition, you can combine two to get the between condition with `np.logical_and`.

It can be done as a one-liner too:

```py
>>> lon_arr
array([[ 20, -40],
       [ 30, -30],
       [ 20, -14],
       [ 30, -30]])
>>> np.asarray(np.where(np.logical_and(lon_arr>=-40, lon_arr<=-10))).T
array([[0, 1],
       [1, 1],
       [2, 1],
       [3, 1]])

```
If `lon_array` is a list of lists (built-in basic data type of Python), using `enumerate(...)`would be the best approach to know the indices of an element:

```
for y, row in enumerate(lon_array):
    for x, value in enumerate(row):
        if -40 <= value <= -10:
            index = (y, x)
            # do something useful with it...

```