Here's a function I created for challenge 7.2 in Dawson book, but wanted to modify it a little bit. To not spam I'm sending just key place as other is not related to the problem.
def results(score):  
     name = input("What's your name? ")
     s = shelve.open("results.dat")
     s[str(score)] = [name]
     s.sync()
     scores = list(s.keys())
     scores.sort(reverse=True)
     print("Top 5 results in quiz game:\n")
     for i in scores[:5]:
         print("Points:", i, "Player:", "".join(s[i]))
     s.close()
My output looks:
Points: 8 player: Chris
Points: 6 player: klsjahd
Points: 5 player: dlahdlksjah
Points: 4 player: dnlsandlknasd
Points: 3 player: bleble
I'd want to add a row number, so I can show obvious thing like which top is it.
TOP 1: Points: 8 player: Chris
TOP 2: Points: 6 player: klsjahd
TOP 3: Points: 5 player: dlahdlksjah
TOP 4: Points: 4 player: dnlsandlknasd
TOP 5: Points: 3 player: bleble
 
    