w3resource logo
Python Exercises

Python NumPy: Create and display every element of an numpy array

Python NumPy: Array Object Exercise-70 with Solution

Write a Python program to create and display every element of an numpy array.

Sample Solution:-

Python Code:

import numpy as np
x = np.arange(12).reshape(3, 4)
for x in np.nditer(x):
    print(x,end=' ')
print()

Sample Output:

0 1 2 3 4 5 6 7 8 9 10 11   

Python Code Editor:

import numpy as np
x = np.arange(12).reshape(3, 4)
for x in np.nditer(x):
    print(x,end=' ')
print()

Improve this sample solution and post your code through Disqus