S06 · Sat, Oct 24, 2026

Build a Themed Collection

Student slides for session S06. Use these to follow along in class or to recap what to try before next time.

The Moonlit trail continues

Build a Themed Collection

Build three related breadcrumb markers in order: Sun Seed, Rain Bell, then Wind Flower. Plan them as Python records, transfer the values to YAML, and follow the trail in the world.

objects = [{...}, {...}, {...}]

Today’s mission

M06 · Build a Curious Collection

Mission: build-an-object-collection

Learning target: Represent exactly three related objects as dictionaries in one list, trace the first iteration of one plain for loop, and print a design inventory before transferring the values to package YAML.

M06 is complete only after you interact with all three objects.

One object

A dictionary is one record

A dictionary keeps the properties of one object together as key-value pairs.

{"name": "Sun Seed", "x": 180, "y": 180, "color": "gold"}
  • The keys are "name", "x", "y", and "color".
  • Each key has one value after its colon.
  • One complete dictionary plans one world object.

Three objects

A list is an ordered collection of records

objects = [
    {"name": "Sun Seed", "x": 180, "y": 180, "color": "gold"},
    {"name": "Rain Bell", "x": 380, "y": 300, "color": "blue"},
    {"name": "Wind Flower", "x": 620, "y": 420, "color": "pink"},
]

Keep exactly three dictionaries. Their list order is the breadcrumb order: Sun Seed → Rain Bell → Wind Flower.

Read one property

Look up a value by key

object_record["x"]

The square brackets ask the current dictionary for the value stored under "x". For the Sun Seed record, the result is 180.

The spelling must match the key exactly. Python does not guess a missing or differently spelled property.

Repeat one block

One plain for loop

for object_record in objects:
    print(
        object_record["name"],
        object_record["x"],
        object_record["y"],
        object_record["color"],
    )

Python takes each dictionary from objects in order, gives it the temporary name object_record, and runs the same indented print.

Predict before running

Trace the first iteration

Do not run the starter yet. Fill in this trace on paper:

object_record is the record named: __________
object_record["x"] is: __________
the first printed line will be: ______________________________

Then circle any duplicate name or coordinate and any missing property you predict will cause trouble.

Python first

Complete the starter

objects = [
    {"name": "Sun Seed", "x": 180, "y": 180, "color": "gold"},
    {"name": "Rain Bell", "x": 380, "y": 300, "color": "blue"},
    {"name": "TODO: third garden object", "x": 620, "y": 420, "color": "green"},
]
  1. Check your first-iteration trace.
  2. Replace only the third record’s TODO name and choose its color.
  3. Keep all four properties in every record.
  4. Run python lessons/sessions/s06/student/starter.py.

Checkpoint

Three inventory lines

A completed canonical example prints:

Sun Seed 180 180 gold
Rain Bell 380 300 blue
Wind Flower 620 420 pink

Point to one lookup in your loop and explain which dictionary supplies its value on the first iteration.

Deliberate debugging

Find the missing y property

broken_record = {
    "name": "Wind Flower",
    "x": 520,
    "color": "pink",
}

print(broken_record["y"])
KeyError: 'y'

The lookup asks for "y", but the record has no such key. Add an integer y property before reading it, then rerun successfully.

Keep the boundary clear

Python plans; YAML drives the Trail

Transfer the intended values
Python recordPackage fileVisible object
objects[0]objects/sun-seed.yamlSun Seed
objects[1]objects/rain-bell.yamlRain Bell
objects[2]objects/wind-flower.yamlWind Flower

Python never executes from the package. The validated YAML values are what the runtime loads into the visible world.

Package rules

Three distinct breadcrumb markers

  • Keep exactly three package objects.
  • Give them distinct names, positions, colors, near responses, and interaction responses.
  • Make Sun Seed lead toward Rain Bell, and Rain Bell lead toward Wind Flower.
  • Let Wind Flower point toward a gate hidden in the sky.

Validate before launching

Ask the package validator

explore-package validate lessons/sessions/s06/student/explorer-package
valid: starlight-garden 0.1.0

If validation fails, read its file and field location. Repair the YAML error separately from the Python KeyError exercise.

Launch M06

Open the standard Trail

explore-package trail \
  examples/explorer-packages/nova-character \
  lessons/sessions/s06/student/explorer-package \
  --player "nova-character:nova" \
  --mission-id "build-an-object-collection" \
  --name "S06 Build a Themed Collection"

This mission uses the standard, plain Trail presentation. Nova and the three package objects are enough; there is no NPC or lantern dependency.

Play the collection

Interact with all three objects

  1. Move Nova near Sun Seed and press E.
  2. Follow its breadcrumb to Rain Bell and press E.
  3. Follow Rain Bell to Wind Flower and press E.
  4. Confirm the mission state changes to Complete only after all three visits.

Scope guard

One list, one loop, three records

Today’s solution has a deliberately small shape:

  • No list comprehension.
  • No nested loop.
  • No second loop.
  • No fourth object.

Strengthen the three existing response strings if you finish early; do not add another mechanic.

Explain your model

Checkpoint before close

  • Dictionary: Which properties belong to one record?
  • List: Why does the order of the three records matter?
  • Loop: What changes from the first iteration to the second?
  • Boundary: Which file plans values, and which files drive the Trail?
  • Mission: Why is M06 incomplete after only two interactions?

Looking ahead

S07 · Create a Two-State Prop

That’s the next session on the class calendar. For now, keep the final breadcrumb’s skyward clue as story only.

Close

Wrap up S06

Save your files. Be ready to trace the first iteration, explain one key lookup, and show that all three objects were required for completion.

What we learned in Python today →