Making Lists

7 min read · Beginner
You will learn
  • How the dash ( - ) creates a list of items
  • Simple lists vs. lists-of-groups (objects in lists)
  • How to put lists inside nested groups and vice versa

Great job! You have learned how to organize information into groups with indentation. Now we will learn how to list many similar items — like a bullet-point list in a document.


Simple lists

Sometimes you need to list multiple things. In YAML, you use a dash (-) to make lists.

Click Next to see each item being added to the list:

Interactive: Making a List

Click Next to see how dashes create a list — like writing bullet points

# Things to test in my chip
tests_to_run:
- "basic_operations"
- "speed_test"
- "power_test"
- "temperature_test"
What YAML sees:
List items will appear here...
Click Next to start building a YAML list step by step.

This is like making a bullet-point list in a document. Each dash is one bullet point.


Lists inside nested groups

A list can live inside a nested group. The dashes are indented under their parent, just like any other child:

chip_tests:
·· project_name: "My First Chip Tests"
·· # List of different tests to run
·· test_list:
···· - "power_test"
···· - "speed_test"
···· - "temperature_test"
· = one space

Here test_list is a child of chip_tests (2 dots of indent). The list items are children of test_list (4 dots). The project_name key and the test_list are siblings — both at 2 dots.


Lists where each item has its own details

Sometimes each item in your list is not just one value — each item has its own details. For example, your chip needs to run different tests, and each test has a name, how long it takes, and whether it is important.

This is like having a to-do list where each item has its own details. Click Next to see how each dash starts a new item:

Interactive: Lists of Objects

Click Next — watch how dashes create separate "index cards," each with its own fields

test_list:
- name: "power_test"
duration: 30
important: true
- name: "speed_test"
duration: 15
important: true
What YAML sees:
List items will appear here as index cards...
Click Next to build a list where each item has multiple fields — like a stack of index cards.

The key rule: a new dash at the same indent level = a new item. No dash = still the same item.

Here is the book’s complete example with all four tests. Count the dots — the list items are at 4 spaces, their fields at 6 spaces:

# Test Configuration for My Chip
chip_tests:
·· project_name: "My First Chip Tests"
·· test_list:
···· - name: "power_test"
······ duration: 30 # minutes
······ important: true
···· - name: "speed_test"
······ duration: 15 # minutes
······ important: true
···· - name: "heat_test"
······ duration: 60 # minutes
······ important: false
···· - name: "basic_function_test"
······ duration: 10 # minutes
······ important: true
· = one space

This is like having a to-do list where each item has its own details.


The deep pattern: nested groups inside list items

Here is the most powerful combination. Each list item can have its own nested group inside it. For example, each test has a settings group with voltage and temperature:

project:
·· name: "My Chip"
·· tests:
···· - name: "power_test"
······ settings:
········ voltage: 1.2
········ temperature: 85
······ expected_result: "pass"
···· - name: "speed_test"
······ settings:
········ frequency: 100
······ expected_result: "pass"
· = one space

Count the indentation levels:

  • 0 dots: project (root)
  • 2 dots: name, tests (children of project)
  • 4 dots: - name: (list items inside tests)
  • 6 dots: settings, expected_result (fields of each test item)
  • 8 dots: voltage, temperature (inside the settings group)

That is four levels deep: project → tests → item → settings → voltage. It looks complex, but every level follows the same rule: indent 2 more spaces = go one level deeper.


Common beginner questions

Q How many spaces should I use for indentation?
Q Can I mix different types of information?
Q What if I make a mistake?
Q Can a list item have its own nested groups?

Key takeaways

  • ✓ Lists use dashes: - item — always put a space after the dash
  • ✓ Each dash at the same indent = one item in the list
  • Lists with details: new dash = new item, no dash = same item
  • ✓ Lists can live inside nested groups — indent the dashes
  • ✓ Each list item can have its own nested groups inside it
  • ✓ You can combine nesting and lists as deep as you need