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
Let me show you another useful function that we'll use just like a range.
Mind you it's not as common as range.
Range you'll see it a lot in Python code but this other one is still very useful.
And it's called enumerate.
Now what does it do.
Let's have a look.
I can do a for loop and I'll say 4 and we'll say character in enumerate and then enumerate.
We wrap around something that well we want to enumerate.
So let's see what that means.
It returns and enumerate to object.
So interval must be an other object that supports iteration.
So we have to give it something that enumerate can iterate over.
So this time around let's just do a a string that says hello.
Now enumerate is special because what it's going to give us is it's going to take an editable object
and gives you an index counter and the item of that index.
What I mean by that.
Well you can actually say I comma character.
So we're unpacking this and we're saying hey print I and character.
If I click Run look at that I get Hello iterated over again.
If we don't have enumerate then we would have just gotten Hello.
But we also because we use enumerate we get this eye or index of each item and where it is in the index
so that if I had a list here let's say 1 2 3 again I'm able to use and access the index number of the
item as well.
What if we had a couple
again we get the index number so enumerate is very useful if you need the index counter of the item
that you're looping through so let's do a little exercise let's say that we want to create a script
that enumerates a list of numbers 1 through 10.
So we'll use range to create that I'm going to say list and then I'm going to say range.
I know there's a lot of functions here range that is one hundred and actually list to that and I want
to be told what the index of the number 50 is.
So pause the video if you need to do that.
Now here I want it so that let me make this a little bit bigger.
I want it so that we only print the index of let's say the value 50.
I want to know where 50 is in the list.
Now again this is a simple example seeking probably already guess what the answer is.
But how would you code this so that only in here we get the index of 50 or it says the index of 50 is
whatever positive video if you want to give it a go.
Otherwise let's try this I'm going to do a conditional and says if character is equal to 50 then I'm
going to print index or I'm going to do an F string and I'll say that the index of 50 is and then I'll
add the index in here so that if I run
I get index of 50 is 50 and just to confirm if for example I just print here and let's say print I in
character I click Run we see that map we have the index is the same as the numbers again not too difficult
of a question but you see here that we're able to extract this information again not as useful as range
but you will see it occasionally in code.
So I wanted to make sure that you're not surprised by it as you can see it's not that difficult.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.