title: I need to know how to sort my dictionary on python by aveage scores with students with multi-ple scores?
body: <p>I have scores of names of pupils in my class who took a quiz. ome took more than one and I want to work out the average using python. I saved the scores in a textfile but im not sure how to programme it so it sorts it by there total scores divided by the amount of times they took there test. im using python 3.4.1.</p>
  
  <pre><code>the text file looks like this : 
  zor:10
  zor:21
  bob:30
  qwerty:46
  </code></pre>
  
  <p>and I have tried to sort it by this :</p>
  
  <pre><code> if schClass == '2':
       schClass = open("scores2.txt", 'r')
       li = open("scores2.txt", 'r')
       data = li.read().splitlines()
       for li in data:
          name = li.split(":")[0]
          score = li.split(":")[1]
          if name not in diction1:
              diction1[name] = score
          elif name in diction1  :
              diction1[name] = (score) + (diction1[name])
              for name in diction1:
                  diction1[name] = int(diction1[name])/3
  </code></pre>