Kodewick
Start learning →
Basic←→0 / 80

Reading club

#044BasicSortingDicts4 min

The reading club noted how many pages each person read this month: {name: pages}. Write reading_rank(pages) to return the names from most pages to fewest. No two counts are the same; nobody gives [].

Examples
reading_rank({"Mia": 120, "Leo": 300, "Ann": 45})→['Leo', 'Mia', 'Ann']
reading_rank({})→[]
main.py
def reading_rank(pages):
    # your code here: sort items() by pages (the 2nd part), biggest first
    ordered = list(pages.items())
    return [name for name, p in ordered]
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.