Hey you can use theindices() method. It is used to create an array of indices that can be used to index into another array. The method returns an array with the same shape as the input array, where each element of the output array contains a tuple of indices that can be used to index into the input array. The where() function is a powerful tool for array manipulation in Python. It returns the indices of elements in an input array where a specified condition is true.
Let’s understand it by an example, you can create 5x5 array having all values 1 and then we find indices and replace all elements except border elements with 0.