← Back to Unit 1

Pet Services: Making and Reading Lists

LESSON • LISTS + TUPLES
🐾 Pet Services Program: Making and Reading Lists
So far, your Pet Services Program has used decisions, loops and functions. Today you will learn how Python stores groups of values using lists and tuples, using the same program you already know.
✅ Today you will learn to…
• Spot lists that already exist in the program
• Explain what a list is and what a tuple is
• Read values from a list using a loop or in
• Decide when data should stay as a list and when it could be a tuple
🎯 Success criteria
You can point to the lists in the Pet Services Program, explain what they do, modify one safely, and convert one suitable example into a tuple.
⚠️ One rule
No random feature creep. Today is about data structures, not inventing new services, prices or rules.
📌 Reminder: why we keep returning to the same program
Good programmers don’t learn ideas in isolation. They learn new ideas by adding them to programs they already understand.
What you already know
The program asks questions, validates inputs, uses decisions to price services, and prints a booking summary.
What is new today
We are looking at how the program stores groups of related values like sizes, services and summary lines.
Today’s goal: same familiar program, deeper understanding of how it stores data.
1️⃣ What we are starting with (the worked program)
This is the Pet Services Program you already know. Today you are reading it with a new question in mind: where is the program storing groups of values?
Show the Pet Services Program
# ------------------------------------------
# Pet Service Booking System
# ------------------------------------------
# This program collects dog information,
# calculates grooming cost based on size and service,
# applies age-based modifiers,
# and prints a clear booking summary.
# ------------------------------------------

# ---- Chunk A: Welcome and Instructions ----

print("Welcome to the Dog Grooming Booking System.")
print("This program is for DOGS only.")
print("Size categories: small (0–10kg), medium (10–25kg), large (25kg+).")
print("Services available: bath, haircut, full.")
print("--------------------------------------------")

# ---- Chunk B: Collect Basic Inputs ----

dog_name = input("Enter your dog's name: ")
dog_breed = input("Enter your dog's breed: ")

# ---- Chunk C: Validate Age Input Using a While Loop ----

# We keep asking until the user gives a sensible number.

while True:
dog_age_input = input("Enter your dog's age in years: ")

```
# Check if the input is a number
if dog_age_input.isdigit():
    dog_age = int(dog_age_input)

    # Age cannot be negative
    if dog_age >= 0:
        break
    else:
        print("Age cannot be negative. Try again.")
else:
    print("Please enter a valid whole number for age.")
```

# ---- Validate Dog Size ----

# This while loop ensures size is one of the allowed options.

valid_sizes = ["small", "medium", "large"]

while True:
dog_size = input("Enter dog size (small / medium / large): ").lower()

```
if dog_size in valid_sizes:
    break
else:
    print("Invalid size. Please type small, medium, or large.")
```

# ---- Display Services Using a For Loop ----

# Instead of writing 3 separate print statements,

# we loop through a list.

services = ["bath", "haircut", "full"]

print("\nAvailable services:")
for service_option in services:
print("-", service_option)

# ---- Validate Service Choice ----

while True:
service = input("Choose a service: ").lower()

```
if service in services:
    break
else:
    print("Invalid service. Please choose from the list above.")
```

# ---- Chunk D: Calculate Base Cost ----

# Base cost depends on BOTH service and size.

if service == "bath":
if dog_size == "small":
base_cost = 20
elif dog_size == "medium":
base_cost = 25
else:
base_cost = 30

elif service == "haircut":
if dog_size == "small":
base_cost = 30
elif dog_size == "medium":
base_cost = 35
else:
base_cost = 40

else:  # full grooming
if dog_size == "small":
base_cost = 45
elif dog_size == "medium":
base_cost = 50
else:
base_cost = 60

# ---- Chunk E: Apply Age Modifiers ----

total_cost = base_cost  # Start with base cost

# Puppy discount

if dog_age < 1:
total_cost = total_cost * 0.9  # Reduce by 10%

# Senior dog fee

if dog_age >= 10:
total_cost = total_cost + 5

# ---- Chunk F: Output Booking Summary ----

# We store summary lines in a list and print them using a for loop.

summary_lines = [
"\n----- Booking Summary -----",
f"Dog name: {dog_name}",
f"Breed: {dog_breed}",
f"Age: {dog_age} years",
f"Size category: {dog_size}",
f"Service selected: {service}",
f"Base cost: ${base_cost:.2f}",
f"Final total cost: ${total_cost:.2f}"
]

for line in summary_lines:
print(line)

print("----------------------------")
2️⃣ What is a list?
The idea
A list stores multiple values in one variable, in order. Lists use [ ] brackets and commas between items.
Example: services = ["bath", "haircut", "full"]
Why this helps
Instead of making separate variables like service1, service2, service3, the program stores them together and can loop through them or check if a value is inside them.
3️⃣ Spot the lists in the Pet Services Program
There are three important lists already in the program. Your first job is to find them and explain what each one is doing.
Task A — Find the list names
Search the code and find the variable names for:
• the list of valid size categories
• the list of service options
• the list of lines used in the booking summary
Checkpoint
You should find:
valid_sizes
services
summary_lines
Task B — Explain what each list does
Write a short explanation for each one:
• What values are stored inside it?
• Why did the programmer choose a list here?
• How does the rest of the program use it?
Hint
Look for places where the list is used with:
in to check membership
for to loop through items
Task C — Worked example: services
Read this example carefully. Use it as your model for writing about the other lists.
services = ["bath", "haircut", "full"]
This list stores the available service options. The program uses it twice:
• first, a for loop prints each service for the user
• second, the program checks whether the user’s choice is in the list
4️⃣ Make and change a list safely
Now you will edit an existing list in the program and observe what changes. This is a safe way to see why lists are powerful.
Step A — Add one new service
Change this line:
services = ["bath", "haircut", "full"]
Add one more service option to the end of the list. For example, you might test "nail trim".
Step B — Run the program and observe
After you edit the list, run the program and answer:
• Does the new service print in the menu?
• Can the user choose it?
• Does the program still price it correctly?
Notice: the menu and the validation will update, but the pricing section will not magically know the cost. That part still depends on your decision code.
Why this matters
A single list can affect multiple parts of the program. That is useful because the data is stored in one place. But it also means you need to think carefully about which rules depend on that data.
5️⃣ How lists are read
In this program, Python reads lists in two main ways: by checking whether a value is inside a list, and by looping through all the items.
Using in
if dog_size in valid_sizes:
This checks whether the user typed one of the allowed size categories.
Using a for loop
for service_option in services:
print("-", service_option)
This goes through the list one item at a time and prints each service on its own line.
Worked example from the program
Here is the exact service list from the Pet Services Program:
services = ["bath", "haircut", "full"]
If the program runs this loop:
for service_option in services:
print("-", service_option)
the output will be:
- bath

* haircut
* full
Key idea: a list stores the values, and the program can then read those values one at a time or check whether something belongs in the list.
6️⃣ What is a tuple?
A tuple is very similar to a list, but it is meant for values that should not change. Tuples use ( ) brackets instead of [ ].
List vs tuple
List
valid_sizes = ["small", "medium", "large"]
Tuple
valid_sizes = ("small", "medium", "large")
Worked example
The size categories in the Pet Services Program are a good tuple candidate because they are meant to stay fixed:
valid_sizes = ("small", "medium", "large")

if dog_size in valid_sizes:
print("Valid size entered")
Even though it is a tuple, the program can still check membership using in.
Simple way to think about it: a list says “these values might change”, while a tuple says “these values are fixed for this program”.
Good tuple examples
Program categories that are meant to stay fixed are often good tuple candidates. In this lesson, valid_sizes is a reasonable example to test as a tuple.
7️⃣ Adding to a list vs trying to add to a tuple
This is the big practical difference. Lists are designed to be changed. Tuples are not.
Worked example: adding to a list
Start with the service list from the program:
services = ["bath", "haircut", "full"]
You can add a new service using append():
services = ["bath", "haircut", "full"]
services.append("nail trim")

print(services)
Output:
['bath', 'haircut', 'full', 'nail trim']
Worked example: trying to add to a tuple
Now try the same idea with a tuple:
valid_sizes = ("small", "medium", "large")
valid_sizes.append("giant")
This will fail because tuples do not have append(). You will get an error like this:
AttributeError: 'tuple' object has no attribute 'append'
Your turn
Try both of these in Thonny:
• add a new service to the services list
• try to add a new size to the valid_sizes tuple
Important idea: choose a list when the data may need to grow or change. Choose a tuple when the data should stay locked.
🛠 Troubleshooting (read this if you get stuck)
My program says there is a syntax error after I changed the list
Check your brackets carefully. Lists use [ ]. Tuples use ( ). Make sure you didn’t mix them.
I added a service and now the program doesn’t price it properly
That is expected unless you also add new pricing logic. The list controls what gets shown and validated. The if / elif / else pricing section still controls the actual cost.
I tried append() on a tuple and got an error
That is normal. Tuples are not designed to grow using append(). That is one of the reasons tuples are useful for fixed data.
I can see the list, but I can’t explain why it exists
Ask yourself: what would the code look like without the list? Usually the answer is “longer, messier, and more repetitive.”
✅ Exit check (before you finish up)
Answer these clearly
1) What is a list?
2) What is a tuple?
3) Why can you use append() with a list but not with a tuple?
Quick self-check
You can point to your program and show:
• one list used with in
• one list used with a for loop
• one example of adding to a list
• one example of why a tuple stays fixed
Programs don’t just store lots and lots of individual values. Good programs organise related values together.