‫All right.
‫It's exercise time.
‫Let's combine everything that we've learned into this challenge.
‫What I want you to do is to create a function called highest even.
‫And this function is going to take a list, data type.
‫And this function for now, we'll just pass.
‫But I want you to fill in this part with whatever you think is going to allow us to achieve this.
‫If I do print highest even and I give it a list of, let's say one, two, three, four, eight.
‫I want the highest even to be printed in this list.
‫And actually, let's do ten here.
‫So the highest even number in this list is ten.
‫Just for fun.
‫Let's add 11 as well.
‫So the answer should be printed here as ten.
‫So based on everything you've learned so far, try to fill this part so that you create your own function.
‫Highest even.
‫Pause the video here.
‫Give it a try.
‫Otherwise, I'm going to go with the answer.
‫So what I want to do here, let's think about this is I want to make sure that, first of all, we only
‫consider the numbers that are even in here.
‫So maybe what I'll do is create a new list called Evens.
‫And Evens is going to be an empty list for now.
‫But I'm going to populate this with all of the.
‫Even number.
‫So I'm going to remove three and 11 from this.
‫So let's do that.
‫I'm going to say four item in lie.
‫If item.
‫Modulo two.
‫Equals zero, which means it's going to be even.
‫Then I'm going to even.
‫Append the item.
‫So I'm going to add it to this new list.
‫And then finally in here, once we have the evens list, I want to find the highest number.
‫Now, you can do this manually and go through it one by one.
‫Or Python comes with a nice function called Max.
‫And as you can see, we give it an iterable and it will tell us what the max number is.
‫In our case, we can just give it evens.
‫And remember, we want to return something from this function.
‫That is what is the highest number.
‫Well, we want to return whatever the max of the evens is.
‫If I run this.
‫I get ten?
‫Awesome.
‫Looks like it's working.
‫Now, some of you may have gotten tricked and tried to return inside of the for loop.
‫But if we do this, remember.
‫That this still works, but we actually return from the function when we hit our first item.
‫If we had another item, let's say two in here and I click Run.
‫We get two.
‫And why is that?
‫Because I'm returning.
‫When we loop the first time through our item, which will be to is to an even number.
‫Yes, it is.
‫So we're going to append and then we're finally returning max events which only contains the item two.
‫So you want to make sure here that the indentation really matters.
‫And if you're returning something from inside a loop, you want to make sure that that's your intended
‫behavior.
‫You usually want to loop through something and then return.
‫So make sure you don't prematurely exit the loop.
‫Nice and simple.
‫Remember, your answer may be different than mine.
‫There are many ways to go about this, but hopefully by practicing this you have a better idea of functions.
‫We now have a great utility function highest even that we can use all over our program.
‫Good job getting this far, and I'll see you in the next one.