title: Python - save variables as keys and values to dict
body: <p>I have a quiz where <code>class</code> is the user's class (either 1,2 or 3), <code>name</code> is the user's name and <code>score</code> is the user's score. If the same user completes the quiz again, the <code>class</code> and <code>name</code> will be the same, but the <code>score</code> will be different. </p>
  
  <p>What I want to do is store the data as:</p>
  
  <pre><code>scores_class1 = {
    'myname': [5, 4, 5, 10, 9],
    'otherperson': [10],
  }
  </code></pre>
  
  <p>If the user is in class 1, his <code>name</code> and <code>score</code> will be stored in the dictionary called <code>scores_class1</code> instead of <code>scores_class2</code> or <code>scores_class3</code> in the format above. Also, if the user already took the quiz once, it will just add his score to the list instead of creating a duplicate key.</p>