00:01
In this video, we want to consider how we would write a python program to remove specific elements from a list and then print out the list.
00:11
So as an example, suppose that we have a sample list of colors and then we have strings to represent each of the colors.
00:22
And originally, we have red, green, white, quotation marks to enclose the strings.
00:29
And then black, pink, yellow.
00:43
We want to remove element 0, 4, and 5.
00:46
Remember, indexing starts at 0.
00:48
1, 2, 3, 4, and 5.
00:52
So we want to get rid of red, pink, and yellow, and just have green, white, and black printed out at the end.
01:00
So we can first use the pop function, which is a built -in function in python to remove a specific elements of a list by their index.
01:09
So we would reference our variable list, which is called colors in this case, then dot to apply the method pop.
01:16
And then we'd put our index.
01:17
We want to remove the element zero, so we can do that.
01:23
Then colors dot pop, we want to remove element four, and then colors...