Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

NumPy Array Iterating

Iterating Arrays

Iterating involves accessing elements one by one.

When working with multi-dimensional arrays in NumPy, we can use a basic Python for loop for this purpose.

If we iterate over a 1-D array, it will sequentially access each element.

Example

Iterate through the elements of the following 1-D array:

import numpy as np

arr = np.array([123])

for x in arr:
  print(x)