print a list of dictionaries in table form
<p>assume I have this list as global list </p>

<pre><code> dataset =[{'Major': 'Biology', 'GPA': '2.4', 'Name': 'Edward'},
           {'Major': 'Physics', 'GPA': '2.9', 'Name':'Emily'},  
           {'Major':'Mathematics', 'GPA': '3.5', 'Name': 'Sarah'}]
</code></pre>

<p>and a want a function print() to print it as </p>

<pre><code> name     major        GPA 
 =============================== 
 edward   Biology      2.4 
 Emily    physics      2.9 
 sarah    mathematics  3.5
</code></pre>

<p>How about this: </p>

<pre><code>from __future__ import print_function

dataset =[{'Major': 'Biology', 'GPA': '2.4', 'Name': 'Edward'},Physics', 'GPA': '2.9', 'Name': 'Emily'},Mathematics', 'GPA': '3.5', 'Name': 'Sarah'}]

[print("%s %s: %s\n"%(item['Name'],item['Major'],item['GPA'])) for item in dataset]
</code></pre>

<p>result: </p>

<pre><code>Edward Biology: 2.4

Emily Physics: 2.9

Sarah Mathematics: 3.5
</code></pre>

python