We’re also able to remove items from a list.
Similar to adding items, we can modify lists by taking off the last item, or we can use indexing to select a specific item and remove it from the list. Removing from the end of a list is often referred to as pop or popping.
Imagine a list of the numbers
1, 4, and 10. Popping from this list would remove
But we can also remove items from the middle of our list.
Removing from index
1 of the list
4, 7, 3 would remove
7. This would leave
For this exercise we will be using new
pop as well as
add at index. Use these to make the list on the left match the list on the right.
Remove at index 0 Add blue at index 1 Pop