title: Loading a matrix of float numbers from a file
body: <p>I have some data like, </p>
  
  <pre><code>  1  2  3  4
    3  5  6  7
    2  8  9  10
  </code></pre>
  
  <p>and my code is</p>
  
  <pre><code>    #!/bin/usr/python
      file=open("fer.txt","r")
      M=[]
      P=[]
      K=[]
      def particle(M,P,K):
          for line in file:
              y=line.split()
              M.append(y)
          for i in range(3):
              for j in range(4):
                  P.append(float(M[i][j]))
              K.append(P)
          return K
     print(particle(M,P,K))
  </code></pre>
  
  <p>and then I got</p>
  
  <pre><code>[[1.0, 2.0, 3.0, 4.0, 3.0, 5.0, 6.0, 7.0, 2.0, 8.0, 9.0, 10.0], [1.0, 
  2.0, 3.0, 4.0, 3.0, 5.0, 6.0, 7.0, 2.0, 8.0, 9.0, 10.0], [1.0, 2.0, 3.0, 
  4.0, 3.0, 5.0, 6.0, 7.0, 2.0, 8.0, 9.0, 10.0]]
  </code></pre>
  
  <p>but I ahould have or I want something like this,</p>
  
  <pre><code>[[1.0, 2.0, 3.0, 4.0,], [3.0, 5.0, 6.0, 7.0],[ 2.0, 8.0, 9.0, 10.0]]
  </code></pre>
  
  <p>Edit for duplicate flag: I dont see how its a duplicate question of mine. I am asking different thing also I am trying to understand why my code doesnt work.</p>