title: Creating a matrix in Python using given positions
body: <p>I have been trying to create a matrix based off of a list of positions</p>
  
  <p>I have a list here: </p>
  
  <pre><code>temp = [7, 0, 6, 0, 0, 4, 0, 0]
  </code></pre>
  
  <p>Edit:
      This list represents an 8x8 matrix. 
  The non-zero numbers in the list represent which row the item exists in the matrix. Its position in temp represents which column the item exists in the matrix. So the first item in temp means that there is an item in the first column, 7th row of the matrix.  </p>
  
  <p>and I want to have a matrix that looks like this:</p>
  
  <pre><code>[[0, 0, 0, 0, 0, 0, 0, 0]
   [7, 0, 0, 0, 0, 0, 0, 0]
   [0, 0, 6, 0, 0, 0, 0, 0]
   [0, 0, 0, 0, 0, 0, 0, 0]
   [0, 0, 0, 0, 0, 4, 0, 0]
   [0, 0, 0, 0, 0, 0, 0, 0]
   [0, 0, 0, 0, 0, 0, 0, 0]
   [0, 0, 0, 0, 0, 0, 0, 0]]
  </code></pre>
  
  <p>where the nonzero digits in the list indicate the position of the 1 in the column. </p>
  
  <pre><code>l = []
  for x in range(1, (len(temp)+1)):
      l1 = []
      count = 1
      for y in temp:
          if count == x:
              l1.append(y)
          else:
              l1.append(0)
          count += 1
      l.append(l1)
  </code></pre>
  
  <p>I have this but it's wrong and outputs the 1 in the wrong list. I have tried everything to try and fix it (somehow this code worked with a 4x4 matrix, and I'm not sure why) but nothing has worked.</p>
  
  <p>Some guidance would be much appreciated.</p>