title: How to use all the elements of the array using for loop?
body: <p>actually, I need to put the returned values of the function (global_displacement(X)) into another running loop.</p>
  <p>can someone please tell me how to obtain the required output?</p>
  <p>and what idiotic mistake I have been doing.</p>
  <p>as every time it gives me only the first([ 0,  0, X[0],  X[1]]) <strong>OR</strong></p>
  <p>the last value([ X[20], X[21], X[53], X[54]]) in the output,</p>
  <p>because of wrong indendation of &quot;return j&quot; in the below written code .</p>
  <pre><code>import numpy as np 
  
  
  X = [ 0.19515612,  0.36477665,  0.244737,    0.42873321, 0.16864666,  0.08636661,  0.05376605, -0.57201897, -0.00935055, -1.24923862,  0.,         -1.53111525,  0.00935055, -1.24923862, -0.05376605, -0.57201897, -0.1686466,
       0.08636661, -0.244737,    0.42873321, -0.19515612,  0.36477665,  0.02279911,  0.  ,        0.3563355 ,  0.01379104,  0.   ,       0.42289958, -0.00747999,  0.   ,       0.0825908,  -0.02949519 , 0.   ,      -0.57435396,
       -0.04074819,  0.   ,      -1.25069528 ,-0.02972642,  0.    ,     -1.53227704, -0.    ,      0.   ,      -1.25069528 , 0.02972642 , 0.   ,      -0.57435396 , 0.04074819 , 0.     ,     0.0825908,   0.02949519,  0.  ,
          0.42289958,  0.00747999 , 0.      ,    0.3563355 , -0.01379104, -0.02279911]
  
  
  
  def global_displacement(X):
      
      global_displacements = np.array( [[ 0,  0, X[0],  X[1]], [ X[0], X[1], X[2], X[3]], [ X[2],  X[3],X[4],  X[5]], [ X[4],X[5],X[6], X[7]],[ X[6],X[7],X[8],X[9]], [ X[8],X[9],X[10], X[11] ], [ X[10], X[11],X[12], X[13]], [ X[12], X[13],X[14], X[15]],[ X[14], X[15],X[16], X[17]],[ X[16], X[17],X[18], X[19]], [ X[18], X[19],X[20], X[21]],[ X[20], X[21], 0, 0],
                              [ X[0], X[1], X[23], X[24]], [ X[2], X[3], X[26],X[27]], [ X[4], X[5], X[29],X[30]], [ X[6], X[7], X[32],X[33]], [ X[8],X[9],X[35], X[36]], [ X[10], X[11], X[38], X[39]], [ X[12], X[13], X[41], X[42]] ,[ X[14], X[15], X[44], X[45]],[ X[16], X[17], X[47], X[48]],[ X[18], X[19], X[50], X[51]], [ X[20], X[21], X[53], X[54]] ] )
      
      for i in (global_displacements):
          j =  i.reshape(4,1)
          return j
  
  print(global_displacement(X))
  </code></pre>
  <p>this is the expected output, and I need to put these values in another loop, by calling this function.</p>
  <pre><code>[[0.        ]
   [0.        ]
   [0.19515612]
   [0.36477665]]
  [[0.19515612]
   [0.36477665]
   [0.244737  ]
   [0.42873321]]
  [[0.244737  ]
   [0.42873321]
   [0.16864666]
   [0.08636661]]
  [[ 0.16864666]
   [ 0.08636661]
   [ 0.05376605]
   [-0.57201897]]
  [[ 0.05376605]
   [-0.57201897]
   [-0.00935055]
   [-1.24923862]]
  [[-0.00935055]
   [-1.24923862]
   [ 0.        ]
   [-1.53111525]]
  [[ 0.        ]
   [-1.53111525]
   [ 0.00935055]
   [-1.24923862]]
  [[ 0.00935055]
   [-1.24923862]
   [-0.05376605]
   [-0.57201897]]
  [[-0.05376605]
   [-0.57201897]
   [-0.1686466 ]
   [ 0.08636661]]
  [[-0.1686466 ]
   [ 0.08636661]
   [-0.244737  ]
   [ 0.42873321]]
  [[-0.244737  ]
   [ 0.42873321]
   [-0.19515612]
   [ 0.36477665]]
  [[-0.19515612]
   [ 0.36477665]
   [ 0.        ]
   [ 0.        ]]
  [[0.19515612]
   [0.36477665]
   [0.        ]
   [0.3563355 ]]
  [[0.244737  ]
   [0.42873321]
   [0.        ]
   [0.42289958]]
  [[0.16864666]
   [0.08636661]
   [0.        ]
   [0.0825908 ]]
  [[ 0.05376605]
   [-0.57201897]
   [ 0.        ]
   [-0.57435396]]
  [[-0.00935055]
   [-1.24923862]
   [ 0.        ]
   [-1.25069528]]
  [[ 0.        ]
   [-1.53111525]
   [ 0.        ]
   [-1.53227704]]
  [[ 0.00935055]
   [-1.24923862]
   [ 0.        ]
   [-1.25069528]]
  [[-0.05376605]
   [-0.57201897]
   [ 0.        ]
   [-0.57435396]]
  [[-0.1686466 ]
   [ 0.08636661]
   [ 0.        ]
   [ 0.0825908 ]]
  [[-0.244737  ]
   [ 0.42873321]
   [ 0.        ]
   [ 0.42289958]]
  [[-0.19515612]
   [ 0.36477665]
   [ 0.        ]
   [ 0.3563355 ]]
  </code></pre>