title: How to print elements of a python list to look like a matrix
body: <p>I have users inputting into my program the degree of a matrix (e.g 3x3 == X=3, Y=3) I then populate a list of 9 values that will make up my 3x3 matrix like so:</p>
  
  <pre><code>    total = x * y  # the x and y values inputted by the user
      i = 1
      while i &lt;= total:
          matrix.append(i)
          i += 1
  </code></pre>
  
  <p>After I have this matrix populated I want to print it out such that I print values matrix[0], [1], [2] in the first row and so on. But I want to do this for any size matrix, I have tried this:</p>
  
  <pre><code>i = 1
  j = 0
  while j &lt; total:
      print matrix[j]
      if not i == x:
          print ''
          i += 1
      else:
          print '\n'
          i = 1
      j += 1
  </code></pre>
  
  <p>With no luck as it prints each value on a new line regardless... Any help is appreciated, thanks!</p>