Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imran - 8
- Joeseph - 10
- Test1 - 6
- Test2 - 4
- Joeseph - 5
- Aaron - 4
- Test1 - 1
- Zzron - 1
- Joeseph - 3
- Test1 - 10
- Joeseph - 4
- with open("highscores.txt", "r+")as file:
- file.seek(0)
- scores = file.readlines()
- user_scores = {}
- for line in scores:
- name, score = line.rstrip('n').split(' - ')
- score = int(score)
- if name not in user_scores or user_scores[name] < score:
- user_scores[name] = score
- for name in sorted(user_scores):
- print(name, '-', user_scores[name])
- Joeseph - 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement