- [Narrator] In this self check exercise,
we'd like you to create a generator expression
that will cube each of the even integers in a list
that has just these numeric values.
Ten, three, seven.
One, nine, four and two.
We'd like you to pass that generator expression
to the function list
to actually create a list from the generated values
and one thing that's interesting
with generator expressions
if you are passing them into a function,
the function calls parenthesis act as the delimiters
for the generator expression in that case.
So you don't need nested parenthesis in the function list
to place the generator expression in there.
You basically just place the contents
of your generator expression directly
into the list function call.
So go ahead and pause the video
and give that a shot.
Then come back to see the answer.
Okay, let's take a look at our answer in this case.
So again we're working with this list of numbers.
So we're saying for each
of the values in this list go ahead
and check whether it's divisible by zero
and include it in the result only if
that condition is true.
So for each of the X values for which
that condition is true,
we're going to cube that value.
And this is a combination
of the generator expression
and the parenthesis using,
that are being used excuse me,
to call the list function.
So the result of this is
that it will actually create the list
containing the results.
And you can see for the even integers
the cube of ten was a thousand.
The cube of four was sixty four
and the cube of two was eight
and that is the list
that was produced by the proceeding statement.