How to Iterate 1-D NumPy Arrays


In this example we will show how to iterate the elements of a 1-D NumPy array in Python.

Source Code

import numpy as np

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

for item in n:
    print(item)

Output:

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