Back to Lesson
Sorting Dict Items by Value
Iterate upon a dictionary sequenced by its values.
Instructions
- You have.
scores = {"Eve": 85, "Alice": 95, "Bob": 75} - You want to print the names ordered by score, highest to lowest.
- Useto get a list of tuples.
sorted(scores.items(), key=lambda item: item[1], reverse=True) - Write a loop to print just the keys (the names) derived from the sorted structure in order.
main.py
main.py
Ctrl + Enter