convert a list to dict with key equal to every unique item and value equal to the indices of the item in the list
<p>For example, I have a list of <code>a = ['a', 'b', 'a']</code>, what is the best code to convert it to <code>b = {'a': [0, 2], 'b': [1]}</code>?</p>

<pre><code>a = ['a', 'b', 'a']
b = dict.fromkeys(set(a), []) # {'a': [], 'b': []}
for i, val in enumerate(a):
  b[val] = b.get(val)+[i]

print (b)
</code></pre>

<p>gives:</p>

<pre><code>{'a': [0, 2], 'b': [1]}
</code></pre>

python