An interesting option is to use argwhere to get indices of elements in question.
To present a more instructive example, assume that we want indices of your arr
where the value is <= 3.
The code to get them is np.argwhere(arr <= 3), getting:
array([[0, 0, 0],
[0, 0, 1],
[0, 1, 0]], dtype=int64)
Meaning that the "wanted" elemens are:
arr[0, 0, 0], arr[0, 0, 1], arr[0, 1, 0],
If you want e.g. to print indices of the "wanted" elements and their values,
you can run:
for ind in np.argwhere(arr <= 3):
print(f'{ind}: {arr.__getitem__(tuple(ind))}')
The result is:
[0 0 0]: 1
[0 0 1]: 2
[0 1 0]: 3
Note also that my code works regardless of the number of dimensions in
your array, whereas in other solutions the number of dimensions is
somehow "fixed" in the code.
[0][0][0]arr==1 or 2 or 3?arr[ np.where( arr=1 )]should display1.where/nonzerogives a tuple of arrays suitable for indexing. Here its 3 arrays sincearris 3d.