DEV Community

TechPlygrnd
TechPlygrnd

Posted on • Edited on

NumPy Tutorial #8: Array Iterating

What is iterating means? basically iterating is going through elements of array one by one. How can we iterating an array? let me explain to you how to do it.


Iterating

For perform iterating in NumPy array, we could just do that by using python basic iteration for list.

import numpy as np

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

# Python basic list iteration
for x in arr:
  print(x)
Enter fullscreen mode Exit fullscreen mode

If you run the code, you will get the following output

1
2
3
Enter fullscreen mode Exit fullscreen mode

There you go, that is how you can perform iteration in NumPy array. Thank you for reading and see you next time!

Top comments (0)