We can add a single element to a list using the
.append() Python method.
Suppose we have an empty list called
garden = 
We can add the element
"Tomatoes" by using the
We see that
garden now contains
When we use
.append() on a list that already has elements, our new element is added to the end of the list:
# Create a list garden = ["Tomatoes", "Grapes", "Cauliflower"] # Append a new element garden.append("Green Beans") print(garden)
['Tomatoes', 'Grapes', 'Cauliflower', 'Green Beans']
Let’s use the
.append() method to manipulate a list.
Jiho works for a gardening store called Petal Power. Jiho keeps a record of orders in a list called
Jiho just received a new order for
append to add this string to
Another order has come in! Use
append to add
orders Jiho has received today.