title: Python - Printing a dictionary as a horizontal table with headers
body: <p>I have a dictionary:</p>
  <pre><code>import math
  import random
  
  d = {1: [&quot;Spices&quot;, math.floor(random.gauss(40, 5))],
      2: [&quot;Other stuff&quot;, math.floor(random.gauss(20, 5))],
      3: [&quot;Tea&quot;, math.floor(random.gauss(50, 5))],
      10: [&quot;Contraband&quot;, math.floor(random.gauss(1000, 5))],
      5: [&quot;Fruit&quot;, math.floor(random.gauss(10, 5))],
      6: [&quot;Textiles&quot;, math.floor(random.gauss(40, 5))]
  }
  </code></pre>
  <p>I want to print it out so it lines up nicely with headers. Can I add the headers to the dictionary and always be sure they come out on top?
  I've seen a few ways to do it vertically but I'd like to have it come out with max column widths close to the max str() or int().</p>
  <p>Example:</p>
  <p>Key___________________Label______________________Number<br />
  1______________________Spices_____________________42<br />
  2______________________Other Stuff_____________16<br />
  etc</p>
  <p>Apparently I can't even do this inside of this editor manually, but I hope the idea comes across.
  I also don't really want the __ either.  Just a place holder.<br />
  Thanks all.</p>