title: Initialize List to a variable in a Dictionary inside a loop
body: <p>I have been working for a while in Python and I have solved this issue using "try" and "except", but I was wondering if there is another method to solve it. </p>
  
  <p>Basically I want to create a dictionary like this:</p>
  
  <pre><code>example_dictionary = {"red":[2,3,4],"blue":[6,7,8],"orange":[10,11,12]}
  </code></pre>
  
  <p>So if I have a variable with the following content:</p>
  
  <pre><code>root_values = [{"name":"red","value":2},{"name":"red","value":3},{"name":"red","value":4},{"blue":6}...]
  </code></pre>
  
  <p>My way to implement the example_dictionary was:</p>
  
  <pre><code>example_dictionary = {}
  for item in root_values:
     try:
         example_dictionary[item.name].append(item.value)
     except:
         example_dictionary[item.name] =[item.value]
  </code></pre>
  
  <p>I hope my question is clear and someone can help me with this.</p>
  
  <p>Thanks.</p>