
Checkpoint
Checkpoint: The Guild Archive
The Guild archive is a maze of folders inside folders. Each folder is a dict. Each key is a name. Each value is either a number (a scroll with that many pages) or another dict (a folder inside).
archive = {
"readme": 1,
"maps": {"north": 3, "south": 5},
"logs": {"2025": {"jan": 2, "feb": 4}},
}
Nobody knows how deep the folders go, so a fixed number of loops won't do. Recursion will: a folder inside a folder is just a smaller version of the same problem.
Assignment
Use recursion for both functions. Use isinstance(value, dict) to
tell a folder from a scroll.
total_pages(folder)returns the total pages of every scroll, however deep. Forarchiveabove it is15.scroll_paths(folder)returns a list of paths to every scroll, in the order the dicts list them. Join names with"/". Forarchiveabove it is["readme", "maps/north", "maps/south", "logs/2025/jan", "logs/2025/feb"].- An empty folder has
0pages and no paths ([]).
Use recursion for both functions. Use isinstance(value, dict) to
tell a folder from a scroll.
total_pages(folder)returns the total pages of every scroll, however deep. Forarchiveabove it is15.scroll_paths(folder)returns a list of paths to every scroll, in the order the dicts list them. Join names with"/". Forarchiveabove it is["readme", "maps/north", "maps/south", "logs/2025/jan", "logs/2025/feb"].- An empty folder has
0pages and no paths ([]).
main.py Python sleeping
Press Run to try your code, then Check to test it.