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
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
Welcome back.
Let's try it.
A simple exercise.
I want you to build a simple counter and this counter is going to count the items in our list.
What does that mean.
Well let's say I have a list and this is a reserved word.
Remember it's an actual word in Python so let's name it my list as a variable.
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
list and sum up the total of the list pauses the video if you need to.
Otherwise let's see how we can do that what I'll do is create a counter variable that will equal to
zero to start off with and then I'll say for item in my list I'm going to counter equals counter plus
item and then at the end I'm going to print counter.
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
be should be correct.
Now when doing this exercise you may have gotten tripped up a bit.
So let's think about this.
Some of you may have made an error where you did the print here but if you did the print here you remember
that it's going to get looped over it's part of this code block because of the indentation and it's
going to print as many times as there are items so you have to make sure that the indentation is like
this so that you get the total.
The other thing that you noticed is that in order for you to keep a counter or a total of all these
items you had to make sure that you had a variable outside of the loop because the loop runs the code
over and over and you needed something on the outside.
That doesn't change because if you moved the counter to zero here well every time the counter would
be reset to zero.
So that by the time we get to 10 counter would be zero.
So you get zero plus 10 which equals 10.
And then you'd get well 10 so you have to be careful here that the indentation is an indication of us
looping and when you loop something and you want to keep a tally or total of something that you have
these issues of making sure that what you want to loop over is inside of this code block but why you
don't want to if you want to have some sort of information that's outside of this loop that you keep
it like this if you weren't tricked by this question.
Good job if you were.
Don't worry it's all part of learning.
I'll see in the next one.
Bob.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.