Just a comment: You sort the values but the name list is still untouched so the names and values in the result are no longer connected. You get the three highest values but the last three names. The output ought to be:
Top 1: Karen 92
Top 2: Josh 90
Top 3: Amin 81
which can be achieved by sorting the dictionary by value (or by item, which I think is the terminology here, but I'm far from sure). Use sorted and provide a key function (which has to be a lambda function as it will be "in-line"):
Top 1: Karen 92
Top 2: Josh 90
Top 3: Amin 81
which can be achieved by sorting the dictionary by value (or by item, which I think is the terminology here, but I'm far from sure). Use sorted and provide a key function (which has to be a lambda function as it will be "in-line"):
scores = {'Josh': 90, 'Adam': 72, 'Amin': 81, 'Narnia': 56, 'Natalie': 65, 'David': 68, 'Karen': 92, 'Elsa': 75} scores = sorted(scores.items(), key=lambda x: x[1], reverse=True) for i in range(3): print(f"Top {i+1}: {scores[i][0]} {scores[i][1]}")