Creating a list of dictionaries in python
<p>I have a following data set that I read in from a text file:</p>

<pre><code>all_examples=   ['A,1,1', 'B,2,1', 'C,4,4', 'D,4,5']
</code></pre>

<p>I need to create a list of dictionary as follows:</p>

<pre><code>lst = [ 
{"A":1, "B":2, "C":4, "D":4 },
{"A":1, "B":1, "C":4, "D":5 } 
]
</code></pre>

<p>I tried using an generator function but it was hard to create a list as such. </p>

<pre><code>attributes = 'A,B,C'
def get_examples():

    for value in examples:
        yield dict(zip(attributes, value.strip().replace(" ", "").split(',')))
</code></pre>