title: Python: creating a dictionary that writes high scores to a file
body: <p>First: you don't have to code this for me, unless you're a super awesome nice guy. But since you're all great at programming and understand it so much better than me and all, it might just be easier (since it's probably not too many lines of code) than writing paragraph after paragraph trying to make me understand it.</p>
  
  <p>So - I need to make a list of high scores that updates itself upon new entries.  <em>So here it goes:</em></p>
  
  <p><strong>First step</strong> - done</p>
  
  <p>I have player-entered input, which has been taken as a data for a few calculations:</p>
  
  <pre><code>import time
  import datetime
  
  print "Current time:", time1.strftime("%d.%m.%Y, %H:%M")
  time1 = datetime.datetime.now()
  a = raw_input("Enter weight: ")    
  b = raw_input("Enter height: ")
  c = a/b
  </code></pre>
  
  <p><strong>Second step</strong> - making high score list</p>
  
  <p>Here, I would need some sort of a dictionary or a thing that would read the previous entries and check if the score (<code>c</code>) is (at least) better than the score of the last one in "high scores", and if it is, it would prompt you to enter your name.</p>
  
  <p>After you entered your name, it would post your name, your <code>a</code>, <code>b</code>, <code>c</code>, and time in a high score list.</p>
  
  <p>This is what I came up with, and it definitely doesn't work:</p>
  
  <pre><code>list = [("CPU", 200, 100, 2, time1)]
  player = "CPU"
  a = 200
  b = 100
  c = 2
  time1 = "20.12.2012, 21:38"
  list.append((player, a, b, c, time1))
  list.sort()
  
  import pickle
  scores = open("scores", "w")
  pickle.dump(list[-5:], scores)
  scores.close()
  
  scores = open("scores", "r")
  oldscores = pickle.load(scores)
  scores.close()
  print oldscores()
  </code></pre>
  
  <p>I <strong>know</strong> I did something terribly stupid, but anyways, thanks for reading this and I hope you can help me out with this one. :-)</p>