Python: fill in missing months with zero
<p>I have a list of dictionaries as shown below. Each dictionary holds the total for a particular month. If a month doesn't appear in the list, for example January, it's total should be zero. </p>

<pre><code>q = [{'total_item': 3, 'month': u'02'}, {'total_item': 1, 'month': u'03'}, {'total_item': 1, 'month': u'05'}, {'total_item': 5, 'month': u'06'}, {'total_item': 6, 'month': u'07'}, {'total_item': 1, 'month': u'10'}, {'total_item': 1, 'month': u'12'}]
</code></pre>

<p>I want to convert the above data structure to a simple list, where the ordinal position represent the month and the value represents the total items. </p>

<pre><code>[0, 3, 1, 0, ...] # 12 entries in total - one for each month
</code></pre>

<p>That is Jan is 0, Feb is 3, March is 1 etc.</p>

<p>I know I can use something like this to get the values present: </p>

<pre><code>result = [r['total_item'] for r in q]
</code></pre>

<p>but how do I create zero value entries for the months that are not present?</p>
