1 00:00:00,730 --> 00:00:02,270 - [Narrator] In this self check exercise, 2 00:00:02,270 --> 00:00:05,160 we'd like you to create a generator expression 3 00:00:05,160 --> 00:00:08,720 that will cube each of the even integers in a list 4 00:00:08,720 --> 00:00:11,190 that has just these numeric values. 5 00:00:11,190 --> 00:00:12,540 Ten, three, seven. 6 00:00:12,540 --> 00:00:14,770 One, nine, four and two. 7 00:00:14,770 --> 00:00:17,020 We'd like you to pass that generator expression 8 00:00:17,020 --> 00:00:18,690 to the function list 9 00:00:18,690 --> 00:00:22,270 to actually create a list from the generated values 10 00:00:22,270 --> 00:00:23,980 and one thing that's interesting 11 00:00:23,980 --> 00:00:25,580 with generator expressions 12 00:00:25,580 --> 00:00:28,740 if you are passing them into a function, 13 00:00:28,740 --> 00:00:33,380 the function calls parenthesis act as the delimiters 14 00:00:33,380 --> 00:00:36,230 for the generator expression in that case. 15 00:00:36,230 --> 00:00:40,370 So you don't need nested parenthesis in the function list 16 00:00:40,370 --> 00:00:42,950 to place the generator expression in there. 17 00:00:42,950 --> 00:00:45,310 You basically just place the contents 18 00:00:45,310 --> 00:00:47,800 of your generator expression directly 19 00:00:47,800 --> 00:00:49,760 into the list function call. 20 00:00:49,760 --> 00:00:51,230 So go ahead and pause the video 21 00:00:51,230 --> 00:00:52,470 and give that a shot. 22 00:00:52,470 --> 00:00:54,120 Then come back to see the answer. 23 00:00:58,300 --> 00:01:01,610 Okay, let's take a look at our answer in this case. 24 00:01:01,610 --> 00:01:05,080 So again we're working with this list of numbers. 25 00:01:05,080 --> 00:01:06,620 So we're saying for each 26 00:01:06,620 --> 00:01:09,060 of the values in this list go ahead 27 00:01:09,060 --> 00:01:11,220 and check whether it's divisible by zero 28 00:01:11,220 --> 00:01:13,480 and include it in the result only if 29 00:01:13,480 --> 00:01:15,080 that condition is true. 30 00:01:15,080 --> 00:01:17,940 So for each of the X values for which 31 00:01:17,940 --> 00:01:19,460 that condition is true, 32 00:01:19,460 --> 00:01:21,950 we're going to cube that value. 33 00:01:21,950 --> 00:01:24,520 And this is a combination 34 00:01:24,520 --> 00:01:27,117 of the generator expression 35 00:01:27,117 --> 00:01:29,110 and the parenthesis using, 36 00:01:29,110 --> 00:01:30,640 that are being used excuse me, 37 00:01:30,640 --> 00:01:33,050 to call the list function. 38 00:01:33,050 --> 00:01:34,430 So the result of this is 39 00:01:34,430 --> 00:01:36,330 that it will actually create the list 40 00:01:36,330 --> 00:01:37,890 containing the results. 41 00:01:37,890 --> 00:01:39,840 And you can see for the even integers 42 00:01:39,840 --> 00:01:41,790 the cube of ten was a thousand. 43 00:01:41,790 --> 00:01:44,300 The cube of four was sixty four 44 00:01:44,300 --> 00:01:46,320 and the cube of two was eight 45 00:01:46,320 --> 00:01:47,830 and that is the list 46 00:01:47,830 --> 00:01:50,793 that was produced by the proceeding statement.