Education digital-technologies year-9
Chapter 8 - Lists
A lesson on storing collections of values and presenting them clearly in summaries.
Chapter 8 introduces lists so the Explorer program can store groups of related values and report them back clearly.
Chapter Navigation
Chapter 8 — Remembering more than one report
EXPLORER · v8 · giving the console memory
Something is still missing
Your console can now keep running, which makes it feel much more realistic. You can log one report, then another, and the program responds each time. However, if you look closely, you will notice something slightly disappointing. Every time you enter a new report, the previous one is gone. The console reacts in the moment, but it does not remember what happened before.
That is not how real tools behave. If you were recording observations during a field trip, you would not erase yesterday’s entry every time you wrote a new one. You would build a record over time.
That is not how real tools behave. If you were recording observations during a field trip, you would not erase yesterday’s entry every time you wrote a new one. You would build a record over time.
We need somewhere to store multiple values
Up to this point, every variable you have created has stored a single value. A location variable stores one location. A temperature variable stores one temperature. That works perfectly when you only care about the most recent entry.
A list is different. A list allows a single variable to hold many values at once. Instead of replacing old information, you can add new information to the collection. Over time, the list grows.
A list is different. A list allows a single variable to hold many values at once. Instead of replacing old information, you can add new information to the collection. Over time, the list grows.
What a list looks like in Python
Lists are written using square brackets. An empty list looks like this:
This line creates a variable called
reports = []
This line creates a variable called
reports and gives it an empty list to start with. As the program runs, we can add new items to that list using the .append() method. Each time we append something, it is placed at the end of the list.EXPLORER v8 (run this)
In this version, the structure of the program remains almost the same. The key difference is that each report is stored instead of forgotten. Pay attention to where the list is created and where new reports are added.
"""
EXPLORER v8 — Chapter 8
This version stores multiple mission reports
using a list.
"""
# Create an empty list to store reports
reports = []
keep_running = True
while keep_running:
print("=" * 44)
print(" EXPLORER CONSOLE ")
print("=" * 44)
mission_location = input("Enter mission location: ")
mission_day = int(input("Enter mission day (whole number): "))
temperature_c = float(input("Enter temperature (°C): "))
# Build a short summary of this report
report_summary = (
"Location: " + mission_location +
" | Day: " + str(mission_day) +
" | Temp: " + str(temperature_c) + " °C"
)
# Add the summary to the list
reports.append(report_summary)
print()
print("Report logged.")
print()
user_choice = input("Log another report? (yes/no): ")
if user_choice.lower() != "yes":
keep_running = False
print()
print("All logged reports:")
print("-" * 44)
# Loop through the list and display each stored report
for report in reports:
print(report)
print("-" * 44)
print("Console shutting down.")
What has changed
The console still collects information in the same way, and it still repeats using a loop. The difference is that it now keeps a record of everything entered during the session. Instead of replacing old values, it adds new ones to a growing list. At the end, it loops through that list and displays every report that was stored.
Your program has moved from reacting in the moment to building a history. That small shift makes it feel far more capable.
Your program has moved from reacting in the moment to building a history. That small shift makes it feel far more capable.