append / insert / del / pop / remove
It’s Friday at Café Meeple, where shelves of games tower like cardboard skyscrapers and the smell of pizza dice (yes, really) is in the air. You’ve been named Shelf Captain: the person who keeps the game library tidy, fresh, and party-ready. Static lists don’t cut it here—new favorites arrive, broken boxes get retired, and someone always insists “Connect 4 belongs next to Sorry!, obviously.”
Imagine your shelf the morning after Board-Game Night. Yesterday’s lineup won’t match tonight’s crowd. Families want Candy Land, the strategy table wants Catan, and someone just donated Azul. Your list needs to grow, shrink, and swap—fast.
Replace an item with another (direct index access)
Append to the end or insert at a specific spot
Delete, pop, or remove to get rid of things
All of this uses familiar indexing + dedicated list methods.
Think of each index as a shelf cubby. If the cubby at position 4 currently holds Uno, you can slide it out and place Connect 4 there instead. Same slot, new game—no permission slip needed. The slot number where the game is, is called the INDEX
You can change the value of any item in the list by using its index.
We create a list of 5 Items.
Then, by looking at slot 4 (the 5th element, because remember, we start counting at 0), we can just give it a new value!
We took the old game out of the cubby and replaced it with a new one!
The night at Café Meeple is heating up! Guests are crowding around the shelves, arguing over which games deserve a prime spot on the “Featured Table.”
Your manager, Ms. D20, just handed you the official Board Game List—but it’s outdated. Last week’s hits (Clue, Monopoly, and Sorry!) are so last season. You’re the Shelf Curator, and tonight your job is to swap out the old for the new.
Each game slot is like a numbered cubby on the wall. You don’t add or delete anything yet—you’re simply performing one-for-one swaps using your magical list-indexing powers. The crowd shouts their suggestions; you update the board in real time. When you’re done, the digital display will glow with the brand-new lineup of modern classics.
Create a list called games with 5 board games of your choice.
Print the original list to show what’s currently on display.
One by one, ask the user to suggest a new title for each existing game.
Replace each old title using its index in the list.
When finished, print the updated list and reveal the new shelf lineup.
Pro Tip: Be creative—this is your chance to build the Ultimate Board Game Shelf.
Make the display below for BONUS POINTS!
I want to see which slot, the old game, and the new game!
The café just got a shipment of shiny new boxes. You can either stick a new game at the end of the shelf (append) or slide one into a specific slot (insert). Think of it like pushing boxes along a row—everything scoots right to make space.
Yes. Just like there are string methods, we can call LIST METHODS to modify our lists. Let's look at some ADDITIVE Methods first
These methods make the lists GROW IN SIZE
A walk-in group begs for “just one more quick game.”
Toss it to the end of the shelf—easy.
The café librarian is picky about vibes: party games up front
You can slide a title into slot 0 and push the row over.
Welcome back to RetroWave TV, where reruns rule and remotes still click. Tonight, you are the Broadcast Director. The studio gave you control of the entire night’s lineup — every channel, every show, every time slot.
But there’s a twist:
The execs keep changing their minds mid-broadcast. You’ll have to replace shows by index, add surprise premieres to the end, and slot in a new pilot episode right where they demand — all in real time.
Create an initial lineup list from user input (3 shows).
Replace 2 shows using indexes provided by the user.
Append two new shows to the end of the list.
Insert one show into a specific slot chosen by the user.
Produce a clean, TV-Guide-style printout (no list brackets — use string formatting and methods instead).
Prompt the user for three favorite shows and store them in a list called lineup.
Print the list as a neat TV schedule, not Python syntax.
Let the user choose which channel number to replace and what new show goes there.
Repeat for a second replacement.
Use direct assignment with the provided indexes.
Ask the user to add two new shows at the end of the list using .append().
Print the updated schedule with new channels appearing at the bottom.
Ask the user which channel number they want to insert a new premiere at, and use .insert(position, item) to slide it right in.
Print the updated schedule with new channels appearing at the bottom.
This is used when you know the position of the item you want to remove from a list
Example: Let's Remove the 2nd List Item
What do you think the output will be??
You should practice this on your own!
The pop() method removes the last item in a list, but lets you work with the item after removing it
Think of this like a stack and popping an item off the top
EXAMPLE:
mystery_inc = ['fred', 'velma', 'daphne', 'shaggy', 'scooby']print(mystery_inc)popped_char = mystery_inc.pop()print(mystery_inc)print(popped_char)This is the EXACT same as pop(), but you can tell it a place to pop the item from!
EXAMPLE:
mystery_inc = ['fred', 'velma', 'daphne', 'shaggy', 'scooby']print(mystery_inc)popped_char = mystery_inc.pop(1)print(mystery_inc)print(popped_char)This is used if you don't know the position of an item, but you know it's value!
You can use a direct value or a variable which contains the thing you want removed
EXAMPLE:
mystery_inc = ['fred', 'velma', 'daphne', 'shaggy', 'scooby']print(mystery_inc)mystery_inc.remove('fred')print(mystery_inc)It’s Saturday at the Bit & Pixel Repair Shop, a tiny nook in downtown Bikini Bottom that smells like dust, plastic, and childhood. You’ve just been promoted to Vault Curator—the person who decides which NES cartridges stay in the glass case and which go to storage.
The problem? The vault is crammed. The owner wants a clean five-slot showcase for today, but customers keep asking to try different classics. You’ll start with a 5-game lineup, then make space like a pro: pull a cartridge when you know its slot, yank the last one for a quick demo, pop a specific position to repair a sticky label, and remove a game by name when someone buys it on the spot.
Your mission: perform each kind of removal while printing a neat mini-log after every action so the shop knows exactly what changed.
You start with a clean slate — five freshly dusted cartridges ready to display. Each title entered becomes part of the vault list: the official museum lineup.
As the curator, you proudly print your inventory, slot by slot, in a little table — because in this vault, every cartridge deserves its own spotlight.
Old Man Cartridge spots a cracked label on the second cartridge — “Looks bad for business!” he grumbles.
Since you know exactly which slot it’s in, you don’t need to search for it. With one swift command, you remove it using the del keyword.
No ceremony, no return value — it’s just gone.
When the glass settles, you print the updated shelf — a bit emptier, but cleaner.
A customer strolls in humming the Mega Man theme. “Hey, can I try that one on the demo console?” This is where pop() shines — you remove the last item from your list, but you store it in a variable so you can still show it off later.
It’s not deleted — it’s just been checked out for display.
Print the new shelf, then proudly announce which game is now spinning in the demo unit.
While you’re polishing the shelf, you notice one cartridge in the middle looks grimy — maybe the contacts are bad. You pop it out of the third slot (index 2) using pop(index) and send it to the repair bench.
Again, you keep the name you popped. Why? Because you’ll probably need to log it or reinsert it later — good curators always keep their records clean.
Once more, you print the vault’s remaining lineup and proudly note which cartridge is getting a makeover.
Suddenly, a collector bursts in. “I’ll give you 500 bells for Metroid right now!”
You don’t need to know where it’s sitting on the shelf — you just know its name.
That’s where remove() saves the day.
You pass the game title directly, and Python hunts it down for you, removing it by value instead of position.
You wipe the glass one last time and print the Final Vault Showcase, featuring only the games that survived the day’s chaos.