# loading library import numpy as np # Create a 2D array array = np.array([[1,2], [3,4]]) # Use np.ndindex() to iterate over the indices of the array for index in np.ndindex(array.shape): value = array[index] print(index, value)