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
Welcome back now.
Up until now we saw the break.
Key word that we can use to break out of a loop and you see here that we're able to loop with a for
loop but with a while loop as soon as we break.
We're done.
We've just well broken out of the loop but could we do that in a for loop.
Let's find out yep.
Break.
Keyword works in a for loop as well but there's actually two other things that we can use besides break.
One is called continue and you can see here again blue highlighting if I do continue here and I click
Run.
There you go.
We get our looping again.
But you're thinking why why do we need this like it seems completely useless right.
Well a break.
When we use the break segment it breaks out of the current and closing loop.
So when we used a break statement we broke out of this loop.
Right.
This whole while loop we just exited it and same with the for loop.
We completely exited it however with a continue what we're saying is hey whatever happens when you hit
this line continue onto the top of the enclosing loop.
So the current closing loop What is it.
It's this for loop.
So it's going to go back to the for loop so that if I do something like print here so that we get it
printed twice or you know what let's just move print down here like that and then.
Same here.
We're going to just print out the bottom after continue.
If I click Run nothing gets printed because as soon as it sees continue it's going to say OK I'm going
to go back to the loop and it's going to keep going keep going keep going until well the loop ends so
that we never actually hit line 10 in line for so that becomes really useful and conditional logic as
well.
Finally the third one is called Pass and Pass is but not very useful.
It essentially does nothing if I click run here and again it shows me here line 10 something's wrong.
Well we have to move print up to the top so that while we don't get my list of index of three which
doesn't exist.
So again going back here if I click Run pass doesn't do absolutely anything it just essentially passes
to the next line.
So why is that ever useful.
It's very rare that you'll see pass in your code but pass is a good way to have let's say a placeholder
while you're coding for example you want to loop through the for loop but we don't know what we want
to do yet in the code.
Let's say that here we're still thinking about it.
If I do this and I click Run I get an error here because what Whoa well expected an indented block because
now the for loop or the python interpreters looking for the next.
Like what am I supposed to do with the loop.
I'm trying to loop and there's no code for me.
So you can add a pass here to at least fill something for the for loop to say hey I'm thinking about
it I'm just going to pass it for now just so you have something so you don't bug me and I'll come back
to it.
So if I click Run that still works.
So pass is one of those place holders that we can use so that there is a line of code that does absolutely
nothing that we can still pass through.
Again a very rare thing to see in production code.
But while you're developing some developers like using passed and there you have it break continue and
pass.
I'll see you 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.