Why Do the Same Thing 100 Times When the Computer Can Do It?
What You'll Learn
How to spot repetitive tasks, create templates that handle variations automatically, and build a generator that produces personalized messages for every friend in your list.
Part 1
The Copy-Paste Problem
Imagine it's the end of the school year and you want to write a nice message to each of your friends. You could write each one from scratch:
"Hey Paige, you're awesome at volleyball and you always make me laugh. Have a great summer!"
"Hey Sadie, you're awesome at dancing and you always share your snacks. Have a great summer!"
"Hey Sam, you're awesome at robotics and you always help with homework. Have a great summer!"
See the problem? You're writing almost the same thing over and over, just changing a few details each time. With 3 friends, that's annoying. With 20 friends, that's painful. With 100? Forget it.
But look closer — there's a pattern here. The message is a template with slots that change:
The Template
"Hey [NAME], you're awesome at [SKILL] and you always [NICE THING]. Have a great summer!"
The structure stays the same. Only the details change. And that means a computer can do it — once you teach it the pattern.
Part 2
Building a Template
We already know how to plug variables into text using + to join strings. Let's build a simple message template:
That works, but all those + signs make it hard to read. Python has a cleaner way to plug values into text:
New Thing · f-strings
Put an f before the opening quotation mark: f"..."
Inside the string, put any variable name in curly braces: {name}
Python automatically replaces {name} with whatever is stored in the variable name.
This is called an f-string (the f stands for "formatted"). It does exactly the same thing as joining with +, but it's much easier to write and read.
Try changing the variables and running it again. The template stays the same — only the details change.
Part 3
Templates Meet Lists
Now here's where it gets powerful. What if we have a list of names and want to generate a message for each one?
Five personalized messages from three lines of code inside the loop. If you had 50 friends in the list, it would still be three lines of code. That's the power of automation — the same pattern applied to different data.
Part 4
Different Details for Different Friends
The messages above are all the same except for the name. But what if we want different compliments for each friend? We can use multiple lists that line up — the first friend matches the first compliment, the second matches the second, and so on:
How Parallel Lists Work
We use range(len(names)) to get the position numbers: 0, 1, 2, 3.
Then names[i], skills[i], and traits[i] all use the same position number i.
When i is 0: we get "Paige", "golfing", "make everyone laugh".
When i is 1: we get "Sam", "robotics", "share your snacks".
The lists must be the same length and in the same order for this to work. Position matters!
Part 5
Adding Variety With Randomness
What if you don't want to write specific compliments for each friend? You can create a list of templates and pick randomly for each person:
Run it several times — each friend gets a different random compliment each time. Same pattern, infinite variety.
Part 6
Building the Generator From User Input
Let's make it interactive — the user enters their friends, and the program generates compliments for all of them:
The Three-Part Template
Instead of one list of compliments, we split it into three parts: openers, middles, and closers.
The program picks one random piece from each list and combines them.
With 4 openers × 6 middles × 4 closers, that's 96 possible combinations — all from three short lists. This is how randomness creates variety from a small amount of content.
Part 7
The Meme Text Generator
The same technique works for anything with a repeating pattern. Memes follow templates too — the same format, different content. Let's build a meme text generator:
New Thing · Avoiding Repeats
We keep a list called shown to track which memes we've already displayed.
while meme in shown: keeps picking a new random meme until it finds one we haven't shown yet.
This is a common pattern: using a while loop to keep trying until you get what you want. We learned while loops in Lesson 5 — here's a new use for them.
Part 8
Automation Is Everywhere
What you just did — creating a template and filling it with different data automatically — is one of the most important ideas in programming. It's called automation, and it's the reason computers are useful.
Think about it:
Real-World Automation
Email newsletters — the same template sent to thousands of people, each with their own name: "Hey {name}, check out our new…"
Report cards — the same layout filled with each student's grades and comments
Video game levels — the same basic patterns (enemies, platforms, coins) arranged differently each time
Social media feeds — the same card layout filled with different posts, images, and usernames
Every time you see the same structure with different content, someone automated it. They found the pattern, built a template, and let the computer fill in the details.
Part 9
What You Just Did
You learned to spot the pattern in repetitive tasks ("the structure is the same, only the details change"), create templates that capture that structure, and use loops to fill in the details automatically.
This combines two thinking skills: pattern recognition (spotting the repeating structure) and abstraction (separating the template from the data). Together, they give you automation — the ability to do something once and have it work a thousand times.
The Big Idea
When you find yourself doing the same thing over and over with small variations, stop and ask: "What's the pattern? What stays the same and what changes?" Then build a template for the constant part and loop through the changing part. That's how you go from doing something 100 times to doing it once.
Thinking Questions
- Where else in your life do you see "the same pattern with different details"? (Hint: think about birthday cards, text messages, even your morning routine.)
- Why is separating the template from the data useful? What happens when you want to change the message for everyone?
- How does combining randomness with templates create variety? How many possible outputs can you get from small lists?
Challenges
Level Up
Challenge 1 · Birthday Card Generator
Create a program that asks for a friend's name, age, and a hobby, then generates 3 different birthday card messages using templates. Use f-strings and include the age in a fun calculation (like "You've had {age * 365} days of being awesome!").
Challenge 2 · Mad Libs Generator
Ask the user for a noun, verb, adjective, and a place. Then fill them into 3 different story templates. Make the stories funny! Each template should use all four words.
Challenge 3 · Batch Message Sender
Build a program where the user can choose a message type (thank you / invitation / reminder), then enter a list of names. Generate the appropriate message for each person. Use different templates for each message type.
Summary
What You Learned
Thinking Skill
Automation — spotting repetitive patterns and building templates that handle them automatically. Ask: "Am I doing the same thing over and over? What stays the same and what changes?"
Python Concepts
f-strings — f"Hello {name}" — the clean way to plug variables into text
Templates — a fixed structure with variable slots
Parallel lists — multiple lists that line up by position
range(len(list)) — loop through positions to access multiple lists at once
Combining randomness + templates — small lists, huge variety
Avoiding repeats — using a "shown" list to track what's been used
Lessons 1–6
Decomposition — break big problems into small steps
Abstraction — decide what details matter
Deductive Reasoning — design rules, gather facts, reach conclusions
Categorization — organize related items into meaningful groups
Pattern Recognition — spot what repeats, what stays the same, what changes
Automation — build templates that handle repetitive tasks