title: How to print a 2D array in a "pretty" format?
body: <p>Hello so let's say I have a 2D array <code>a = [[1,2,1,2], [3,4,5,3], [8,9,4,3]]</code> and I would like to print this out in a grid like table. So far the code I have is:</p>
  
  <pre><code>def printArray(a):
      for row in range(len(a[0])):
          for col in range (len(a[0])):
              b = print("{:8.3f}".format(a[row][col]), end = " ")
          print(b)
  </code></pre>
  
  <p>When this is printed out it gives me:</p>
  
  <pre class="lang-none prettyprint-override"><code>  1.000    2.000    1.000    2.000 None
    3.000    4.000    5.000    3.000 None
    8.000    9.000    4.000    3.000 None
  </code></pre>
  
  <p>And then the error:</p>
  
  <pre class="lang-none prettyprint-override"><code>File "hw8pr2.py", line 17, in printArray
  b = print("{:8.3f}".format(a[row][col]), end = " ")
  
  IndexError: list index out of range
  </code></pre>
  
  <p>Can someone tell me why this is happening? I don't want the 'None' at the end of each row either. I want it to output:</p>
  
  <pre class="lang-none prettyprint-override"><code>  1.000    2.000    1.000    2.000
    3.000    4.000    5.000    3.000
    8.000    9.000    4.000    3.000
  </code></pre>