- [Instructor] In this Self Check exercise,
I'd like you to go ahead and create a list of integers
containing these five values,
then use the list method index that we just demonstrated
to you to search for both the values 43 and 44.
And of course, 43 will be in the list, and 44 will not.
Now when you do search for 44,
make sure that no value error occurs.
So go ahead and pause the video
and give that a shot and then come back here
to see the results.
Okay, let's check out the results.
So first, we need to create that list.
Now, we happen to know in this case that 43 is in the list.
So for this one, we simply are going to evaluate
the expression numbers.index with 43 as an argument,
and we know we don't need to worry about an exception
occurring just because we can see what we put into the list.
Of course, you may want to program
that differently in a more robust application.
But for the second piece here,
where we wanna search for the value 44.
Again, we can validate that the value
is in the list before we perform the indexing operation.
So if 44 is found in the list called numbers,
then and only then will we go ahead
and actually search for the value
and find out its index,
otherwise, we're going to print that 44 is not found.
So let's execute that and indeed 44 is not found.