1 00:00:00,810 --> 00:00:02,420 - [Instructor] In this self check exercise, 2 00:00:02,420 --> 00:00:05,130 I'd like you to work with the DEL statement 3 00:00:05,130 --> 00:00:07,690 that we introduced in the preceding video. 4 00:00:07,690 --> 00:00:10,680 So, start out by first creating a list call numbers 5 00:00:10,680 --> 00:00:12,640 with the values one through 15. 6 00:00:12,640 --> 00:00:15,300 And then perform the following two tasks. 7 00:00:15,300 --> 00:00:17,290 Go ahead and delete a slice 8 00:00:17,290 --> 00:00:19,460 that just contains the first four elements, 9 00:00:19,460 --> 00:00:22,170 and show that those elements were removed. 10 00:00:22,170 --> 00:00:24,130 Then delete a slice that starts with 11 00:00:24,130 --> 00:00:25,210 the first element, 12 00:00:25,210 --> 00:00:26,860 and removes every 13 00:00:26,860 --> 00:00:28,970 other element from that point forward 14 00:00:28,970 --> 00:00:30,240 in the rest of the list, 15 00:00:30,240 --> 00:00:33,260 and show us the resulting list once again. 16 00:00:33,260 --> 00:00:34,630 So, go ahead and pause the video 17 00:00:34,630 --> 00:00:35,650 to give those a shot, 18 00:00:35,650 --> 00:00:37,503 then come back to see the answers. 19 00:00:41,390 --> 00:00:43,260 Okay, lets reveal the answers 20 00:00:43,260 --> 00:00:45,270 by first creating the list with 21 00:00:45,270 --> 00:00:47,090 the numbers from one through 15. 22 00:00:47,090 --> 00:00:49,360 So again we're using the range function 23 00:00:49,360 --> 00:00:52,150 to make that super quick and easy for us. 24 00:00:52,150 --> 00:00:53,100 And of course, 25 00:00:53,100 --> 00:00:56,440 we want to see that those values are in the list. 26 00:00:56,440 --> 00:00:59,250 So, the first thing we wanna do now that we have our list, 27 00:00:59,250 --> 00:01:01,250 is delete those first four elements, 28 00:01:01,250 --> 00:01:03,210 the numbers from one through four. 29 00:01:03,210 --> 00:01:06,350 So, let's do that with the DEL statement. 30 00:01:06,350 --> 00:01:07,790 So, here's a slice 31 00:01:07,790 --> 00:01:08,623 that says, 32 00:01:08,623 --> 00:01:11,020 Give me a subset of numbers, 33 00:01:11,020 --> 00:01:12,730 stating from index zero up to, 34 00:01:12,730 --> 00:01:14,850 but not including index four. 35 00:01:14,850 --> 00:01:15,810 So that gives me, 36 00:01:15,810 --> 00:01:18,260 zero, one, two, and three positions. 37 00:01:18,260 --> 00:01:20,860 The fist four elements of that list. 38 00:01:20,860 --> 00:01:22,020 So, if we delete that 39 00:01:22,020 --> 00:01:24,110 and then show you the result afterwards, 40 00:01:24,110 --> 00:01:26,120 you can see that one through four, 41 00:01:26,120 --> 00:01:29,010 have now been removed from the list. 42 00:01:29,010 --> 00:01:31,210 Now, for the second part of the exercise, 43 00:01:31,210 --> 00:01:32,540 we want to delete 44 00:01:32,540 --> 00:01:33,540 every other element. 45 00:01:33,540 --> 00:01:35,450 Starting with the first one. 46 00:01:35,450 --> 00:01:37,190 So, here is an expression 47 00:01:37,190 --> 00:01:38,023 that will do that. 48 00:01:38,023 --> 00:01:39,750 Again, we'll infer 49 00:01:39,750 --> 00:01:42,130 index zero as the start here. 50 00:01:42,130 --> 00:01:43,160 We will infer 51 00:01:43,160 --> 00:01:45,150 the entire length of the remaining 52 00:01:45,150 --> 00:01:47,710 list as the second index in this slice. 53 00:01:47,710 --> 00:01:49,200 And then we're saying, 54 00:01:49,200 --> 00:01:52,330 go every other element through that slice. 55 00:01:52,330 --> 00:01:53,500 So, at this point 56 00:01:53,500 --> 00:01:56,800 we expect to remove five, seven, nine, etc. 57 00:01:56,800 --> 00:01:58,650 And the resulting list, 58 00:01:58,650 --> 00:02:02,143 now contains just the remaining even integers.