making a dictionary from two lists using indices
<p>I have two lists:</p>

<pre><code>alist =  [11,12,13,11,15]
blist = ['A', 'A', 'B', 'A', 'B']
</code></pre>

<p>I want to make a dictionary where items in blist are keys and items in alist are values with lists corresponding to indices in the two lists:</p>

<p>the outcome should be:</p>

<pre><code>{'A': [11, 12, 11], 'B': [13, 15]}
</code></pre>

<p>I have tried this:</p>

<pre><code>dictNames = {}
for i in xrange(len(alist)):
    for letter in blist:
        if letter not in dictNames:
            dictNames[letter] = []
        else:
            dictNames[letter].append(alist[i])
</code></pre>

<p>which gives the outcome:</p>

<pre><code>{'A': [11, 11, 12, 12, 12, 13, 13, 13, 11, 11, 11, 15, 15, 15], 'B': [11, 12, 12, 13, 13, 11, 11, 15, 15]}
</code></pre>

<p>Why does it not append to the pre-existing letter in the dictionary instead of adding to it when it is already in the dictionary? </p>
