w3resource logo

:

Python Exercises

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

Python NumPy: Array Object Exercise-71 with Solution

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

Sample Solution:-

Python Code:

import numpy as np
x = np.arange(12).reshape(3, 4)
print("Elements of the array in Fortan array:")
for x in np.nditer(x, order="F"):
    print(x,end=' ')
print("\n")

Sample Output:

Elements of the array in Fortan array:                                 
0 4 8 1 5 9 2 6 10 3 7 11   

Python Code Editor:

Improve this sample solution and post your code through Disqus