Adding stuff to a Python List
Based on NetworkChuck's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Use supplies.append(value) to add exactly one item to the end of a list.
Briefing
Python lists become genuinely useful once code can modify them on the fly—like adding forgotten camping supplies without manually editing the data. The core takeaway is that list “methods” provide built-in operations for inserting or appending items, and choosing the right method determines where new elements land and whether one or multiple items get added.
The lesson starts with the append method. Given an existing list named supplies, adding “toilet paper” is done by calling supplies.append("toilet paper"). Running the script shows the new item appears at the end of the list. That behavior is the defining feature of append: it adds exactly one piece of data per call, always to the tail of the list.
When the goal shifts to adding two items—“toilet paper” and a “bidet”—a single append call won’t work if it tries to cram both values in at once. The workaround is extend, which adds multiple items by taking another list as input. Using supplies.extend(["toilet paper", "bidet"]) results in both elements being appended to the end of supplies. The transcript also notes an alternative that achieves the same effect without extend: list concatenation. By writing supplies = supplies + ["toilet paper", "bidet"], the code creates a new combined list where the added items appear at the end.
The discussion then moves from “adding to the end” to “controlling position.” For that, insert comes in. insert takes two arguments: an index position and the value to add. To place the “bidet” at the very beginning, the code uses supplies.insert(0, "bidet"). This relies on the idea that lists are ordered and indexed (0, 1, 2, …). To insert near the end, negative indices are used: insert(-1, "toilet paper") places the item second to last, because -1 refers to the last position in indexing logic. The same pattern generalizes—negative values shift the insertion point backward, so insert(-2, ...) targets the third-from-last position.
By the end, the practical rules are clear: use append for one item at the end, extend (or list concatenation) for adding multiple items at once, and insert for placing items anywhere in the list by index—including using negative indices to count from the end. The next planned step is removing items with additional list methods, continuing the theme of building real, flexible list manipulation skills.
Cornell Notes
Python list methods let code add and place items without manual editing. append adds one element to the end of a list (e.g., supplies.append("toilet paper")). To add multiple elements at once, extend takes a list of new items (supplies.extend(["toilet paper", "bidet"])) or the same effect can be achieved with list concatenation (supplies = supplies + [ ... ]). When the position matters, insert(index, value) places an element at a specific index, including index 0 for the beginning. Negative indices work with insert too: insert(-1, value) targets the second-to-last position, and insert(-2, value) targets the third-from-last.
Why does append only add one item at a time, and where does it place that item?
How do you add multiple items to the end of a list in one operation?
What’s the difference between extend and insert?
How does insert(0, value) behave?
How do negative indices change insertion positions?
Review Questions
- When would you choose append over extend or insert? Give a concrete example with one camping item vs two items.
- If supplies is already populated, what does supplies.insert(0, "bidet") do to the existing order?
- What insertion call would place an item third from the end using negative indices?
Key Points
- 1
Use supplies.append(value) to add exactly one item to the end of a list.
- 2
Use supplies.extend([value1, value2, ...]) to add multiple items to the end in one step.
- 3
List concatenation can replace extend: supplies = supplies + [value1, value2, ...].
- 4
Use supplies.insert(index, value) to add an item at a specific position, not just the end.
- 5
insert(0, value) places the item at the beginning of the list.
- 6
Negative indices with insert count from the end (e.g., insert(-1, value) targets the second-to-last position).