the thing is that you need to use an array instead of a list to use where properly (also, use True and False instead of 1 and 0 to get a mask to look for the indexes):
A = ['apple', 'orange', 'apple', 'banana']
arr_mask = np.where(np.array(A) == 'apple',True,False)
arr_index = np.arange(0, len(A))[arr_mask]
This way, you'll get arr_index as:
np.array([0,2])
Notice that to use the mask arr_mask or the indexes arr_index to look for the values in A, A needs to be an array:
In [55]: A = ['apple', 'orange', 'apple', 'banana']
...: arr_mask = np.where(np.array(A) == 'apple',True,False)
...: arr_index = np.arange(0, len(A))[arr_mask]
In [56]: A[arr_mask]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-56-f8b153319425> in <module>
----> 1 A[arr_mask]
TypeError: only integer scalar arrays can be converted to a scalar index
In [57]: A[arr_index]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-57-91c260fe71ab> in <module>
----> 1 A[arr_index]
TypeError: only integer scalar arrays can be converted to a scalar index
In [58]: B = np.array(A)
In [59]: B[arr_mask]
Out[59]: array(['apple', 'apple'], dtype='<U6')
In [60]: B[arr_index]
Out[60]: array(['apple', 'apple'], dtype='<U6')
What you are getting using just the list is that the function np.where() doesn't find anywhere where the condition is satisfied. If you try:
A = ['apple', 'orange', 'apple', 'banana']
arr_index = np.where(A == 'orange',1,0)
You'll get again array(0) as the output.