Print Value of Key in Lists of Dicts in Python
<p>I am trying to print the value of a specific key in a list of dicts:</p>

<p>eg:</p>

<pre><code>list = [{'a' : 123, 'b': 'xyz', 'c': [1,2]}, {'a' : 456, 'b': 'cde', 'c': [3,4]}] 
</code></pre>

<p>I was hoping to be able to print the following for each dict:</p>

<pre><code>print ("a: ", a)
print ("b: ", b)
</code></pre>

<p>How about some nested loops, to avoid hard-coding it?</p>

<pre><code>for dictionary in list: # rename list so you don't overshadow the builtin list
    for key in ('a', 'b'):
        print(key + ':', dictionary[key])
</code></pre>

<p>which should output:</p>

<pre><code>a: 123
b: xyz
a: 456
b: cde
</code></pre>

python dictionary