Saturday, 19 September 2026
PastThree rungs, one idea. Solving rung 1 counts. Climb as far as you can.
Who Has The Most
dictionaries + comparing values
Count all the marbles
Write a function called total_marbles
bag is a dictionary where each key is a name and each value is how many marbles that person has. Return how many marbles everybody has altogether. An empty dictionary returns 0.
Examples
| Input | Output |
|---|---|
| {"ana": 3, "bo": 4} | 7 |
| {} | 0 |
| {"ana": 5} | 5 |
| {"ana": 0, "bo": 0} | 0 |
There are extra hidden tests, so make it work in general, not just for these.
Who has the most
Write a function called most_marbles
Same dictionary. Return the name of the person with the most marbles. If two people have the same number, return the one that appears first in the dictionary. An empty dictionary returns None.
Examples
| Input | Output |
|---|---|
| {"ana": 3, "bo": 4} | "bo" |
| {"ana": 4, "bo": 4} | "ana" |
| {} | None |
| {"cy": 7} | "cy" |
There are extra hidden tests, so make it work in general, not just for these.
The top two
Write a function called top_two
Return a list of the two names with the most marbles, the biggest first. When two people have the same number, the one appearing first in the dictionary goes first. If there is only one person, return a list holding just that name, and an empty dictionary returns an empty list.
Examples
| Input | Output |
|---|---|
| {"ana": 3, "bo": 4, "cy": 1} | ["bo", "ana"] |
| {"ana": 2} | ["ana"] |
| {} | [] |
| {"ana": 5, "bo": 5, "cy": 5} | ["ana", "bo"] |
There are extra hidden tests, so make it work in general, not just for these.
Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.