Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. Imran - 8
  2. Joeseph - 10
  3. Test1 - 6
  4. Test2 - 4
  5. Joeseph - 5
  6. Aaron - 4
  7. Test1 - 1
  8. Zzron - 1
  9. Joeseph - 3
  10. Test1 - 10
  11. Joeseph - 4
  12.  
  13. with open("highscores.txt", "r+")as file:
  14. file.seek(0)
  15. scores = file.readlines()
  16.  
  17. user_scores = {}
  18. for line in scores:
  19. name, score = line.rstrip('n').split(' - ')
  20. score = int(score)
  21. if name not in user_scores or user_scores[name] < score:
  22. user_scores[name] = score
  23.  
  24. for name in sorted(user_scores):
  25. print(name, '-', user_scores[name])
  26.  
  27. Joeseph - 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement