All language subtitles for 12. Exercise Tricky Counter

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,830 --> 00:00:01,840 Welcome back. 2 00:00:01,850 --> 00:00:02,370 Let's try it. 3 00:00:02,370 --> 00:00:04,490 A simple exercise. 4 00:00:04,490 --> 00:00:13,730 I want you to build a simple counter and this counter is going to count the items in our list. 5 00:00:13,730 --> 00:00:14,720 What does that mean. 6 00:00:14,720 --> 00:00:22,210 Well let's say I have a list and this is a reserved word. 7 00:00:22,220 --> 00:00:29,260 Remember it's an actual word in Python so let's name it my list as a variable. 8 00:00:29,380 --> 00:00:42,600 And this list has 1 2 3 4 5 6 7 8 9 what I want you to do is using looping to loop over this editable 9 00:00:42,750 --> 00:00:49,030 list and sum up the total of the list pauses the video if you need to. 10 00:00:49,120 --> 00:00:59,460 Otherwise let's see how we can do that what I'll do is create a counter variable that will equal to 11 00:00:59,460 --> 00:01:15,810 zero to start off with and then I'll say for item in my list I'm going to counter equals counter plus 12 00:01:16,470 --> 00:01:24,360 item and then at the end I'm going to print counter. 13 00:01:24,560 --> 00:01:32,840 Let's see if this works I'm going to hit run and I get fifty five which if my quick math is right should 14 00:01:32,840 --> 00:01:34,490 be should be correct. 15 00:01:34,550 --> 00:01:39,850 Now when doing this exercise you may have gotten tripped up a bit. 16 00:01:40,040 --> 00:01:41,610 So let's think about this. 17 00:01:41,680 --> 00:01:48,860 Some of you may have made an error where you did the print here but if you did the print here you remember 18 00:01:48,860 --> 00:01:55,790 that it's going to get looped over it's part of this code block because of the indentation and it's 19 00:01:55,790 --> 00:02:03,880 going to print as many times as there are items so you have to make sure that the indentation is like 20 00:02:03,880 --> 00:02:07,110 this so that you get the total. 21 00:02:07,130 --> 00:02:15,410 The other thing that you noticed is that in order for you to keep a counter or a total of all these 22 00:02:15,470 --> 00:02:22,850 items you had to make sure that you had a variable outside of the loop because the loop runs the code 23 00:02:22,970 --> 00:02:26,630 over and over and you needed something on the outside. 24 00:02:26,690 --> 00:02:35,510 That doesn't change because if you moved the counter to zero here well every time the counter would 25 00:02:35,510 --> 00:02:37,150 be reset to zero. 26 00:02:37,220 --> 00:02:41,030 So that by the time we get to 10 counter would be zero. 27 00:02:41,030 --> 00:02:44,070 So you get zero plus 10 which equals 10. 28 00:02:44,270 --> 00:02:54,380 And then you'd get well 10 so you have to be careful here that the indentation is an indication of us 29 00:02:54,500 --> 00:02:59,930 looping and when you loop something and you want to keep a tally or total of something that you have 30 00:02:59,930 --> 00:03:07,490 these issues of making sure that what you want to loop over is inside of this code block but why you 31 00:03:07,490 --> 00:03:12,590 don't want to if you want to have some sort of information that's outside of this loop that you keep 32 00:03:12,590 --> 00:03:16,970 it like this if you weren't tricked by this question. 33 00:03:17,020 --> 00:03:19,330 Good job if you were. 34 00:03:19,330 --> 00:03:21,230 Don't worry it's all part of learning. 35 00:03:21,280 --> 00:03:22,550 I'll see in the next one. 36 00:03:22,780 --> 00:03:23,020 Bob. 3670

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