Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
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 the highest even and this function is going to
take a list data.
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 1 2 3 4 8 I want the highest even to be
printed in this list.
And actually let's do 10 here.
So the highest even number in this list is 10 just for fun.
That's at eleven as well.
So the answer should be printed here as 10 so based on everything you've learned so far.
Try to fill this part so that you create your own function.
Hi Stephen 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 events is going to be an empty
list for now but I'm going to populate this with all of the even numbers so I'm going to remove three
and 11 from this so let's do that.
I'm going to say for item in ally if item modulo 2 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 interval and it'll 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 10 awesome looks like it's working.
Now some of you may have gotten tricked and tried to return inside of the four.
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 two is to an even number.
Yes it is.
So we're going to append and then we're finally returning Max evens 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 up.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.