How to Iterate On Each Scalar Element of 2-D Array in Python


In this example we will show how to iterate on each scalar element of the 2-D array in Python.

Source Code

import numpy as np

n = np.array([[1, 2], [3, 4]])

for x in n:
    for y in x:
        print(y)

Output:

1
2
3
4
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments