All language subtitles for 14. enumerate()

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,860 --> 00:00:06,680 Let me show you another useful function that we'll use just like a range. 2 00:00:06,680 --> 00:00:08,550 Mind you it's not as common as range. 3 00:00:08,570 --> 00:00:13,820 Range you'll see it a lot in Python code but this other one is still very useful. 4 00:00:13,970 --> 00:00:16,950 And it's called enumerate. 5 00:00:17,120 --> 00:00:18,680 Now what does it do. 6 00:00:18,680 --> 00:00:19,790 Let's have a look. 7 00:00:19,850 --> 00:00:28,690 I can do a for loop and I'll say 4 and we'll say character in enumerate and then enumerate. 8 00:00:28,700 --> 00:00:32,840 We wrap around something that well we want to enumerate. 9 00:00:32,870 --> 00:00:34,510 So let's see what that means. 10 00:00:34,580 --> 00:00:37,410 It returns and enumerate to object. 11 00:00:37,620 --> 00:00:41,060 So interval must be an other object that supports iteration. 12 00:00:41,060 --> 00:00:45,300 So we have to give it something that enumerate can iterate over. 13 00:00:45,320 --> 00:00:50,540 So this time around let's just do a a string that says hello. 14 00:00:50,540 --> 00:00:58,400 Now enumerate is special because what it's going to give us is it's going to take an editable object 15 00:00:58,430 --> 00:01:03,790 and gives you an index counter and the item of that index. 16 00:01:04,040 --> 00:01:04,970 What I mean by that. 17 00:01:05,570 --> 00:01:09,910 Well you can actually say I comma character. 18 00:01:10,010 --> 00:01:18,020 So we're unpacking this and we're saying hey print I and character. 19 00:01:18,020 --> 00:01:27,090 If I click Run look at that I get Hello iterated over again. 20 00:01:27,100 --> 00:01:31,770 If we don't have enumerate then we would have just gotten Hello. 21 00:01:31,900 --> 00:01:42,670 But we also because we use enumerate we get this eye or index of each item and where it is in the index 22 00:01:43,660 --> 00:01:54,380 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 23 00:01:54,380 --> 00:01:57,140 item as well. 24 00:01:57,220 --> 00:01:59,260 What if we had a couple 25 00:02:04,800 --> 00:02:15,970 again we get the index number so enumerate is very useful if you need the index counter of the item 26 00:02:16,000 --> 00:02:25,500 that you're looping through so let's do a little exercise let's say that we want to create a script 27 00:02:25,800 --> 00:02:30,410 that enumerates a list of numbers 1 through 10. 28 00:02:30,420 --> 00:02:35,760 So we'll use range to create that I'm going to say list and then I'm going to say range. 29 00:02:35,790 --> 00:02:43,140 I know there's a lot of functions here range that is one hundred and actually list to that and I want 30 00:02:43,380 --> 00:02:50,440 to be told what the index of the number 50 is. 31 00:02:50,440 --> 00:02:53,700 So pause the video if you need to do that. 32 00:02:53,910 --> 00:02:58,830 Now here I want it so that let me make this a little bit bigger. 33 00:02:58,920 --> 00:03:05,070 I want it so that we only print the index of let's say the value 50. 34 00:03:05,130 --> 00:03:09,300 I want to know where 50 is in the list. 35 00:03:09,300 --> 00:03:14,030 Now again this is a simple example seeking probably already guess what the answer is. 36 00:03:14,160 --> 00:03:22,740 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 37 00:03:22,800 --> 00:03:25,960 whatever positive video if you want to give it a go. 38 00:03:25,980 --> 00:03:39,000 Otherwise let's try this I'm going to do a conditional and says if character is equal to 50 then I'm 39 00:03:39,000 --> 00:03:52,040 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 40 00:03:52,100 --> 00:03:57,260 add the index in here so that if I run 41 00:04:00,230 --> 00:04:11,230 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 42 00:04:11,440 --> 00:04:22,170 character I click Run we see that map we have the index is the same as the numbers again not too difficult 43 00:04:22,230 --> 00:04:29,130 of a question but you see here that we're able to extract this information again not as useful as range 44 00:04:29,190 --> 00:04:31,200 but you will see it occasionally in code. 45 00:04:31,200 --> 00:04:36,470 So I wanted to make sure that you're not surprised by it as you can see it's not that difficult. 4666

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.