All language subtitles for 15. While Loops with Break and Continue

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
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
sr Serbian
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

Original subtitles

0 In the previous video we built this code. The code goes like this. 1

We assign the empty string to user name variable, and then we build a while loop which checks if this 2

condition is true. 3

So if the condition of that user name is different from pypy. 4

If user name is different from pypy, this is going to be executed. 5

So in the first iteration user name is actually different from pypy because user name is an empty 6

string. 7

Therefore this is going to be executed. 8

The program asks for the user name. If the input is a for example a will be assigned to user name and 9

then the second iterations starts. 10

So while A is different from pypy which is true, this is going to be executed again. 11

That's why we get these prompt here again. 12

If you enter pypy, the loop ends because in the third iteration pypy is not different from 13

pypy, so this will not occur anymore. 14

Now there is a different way to do this using a brake statement instead of doing the above. 15

Let me 16

do it another way. 17

Again using the while loop but this time you want to check if true. 18

While true which is always true so the loop will always execute until we break it, so while true 19

we want to ask for the user name, input enter the user name. 20

Now we want to create a conditional here to check inside the while loop. 21

So if user name is pypy, and break the loop. 22

Else continue. 23

Let's see what this will give us Python 3 24

b.py. 25

That's the right side script. 26

Enter username. 27

Nope. 28

Nope. 29

Pypy. 30

Yes. 31

Let me try again. 32

If you enter pypy right away again the loop terminates. 33

I do prefer this actually because it gives you more control of the workflow. 34

So this is what's happened here, while true which is always true. 35

So the first iteration occurs because true is true, and we ask for the user name in the first iteration. 36

So in the first iteration here the user name was asfd. 37

So if asfd is equal to pypy breaks the loop. That is not the case because asfd is different then 38

pypy. 39

Therefore this will not occur because this condition is false. 40

Else will be executed. 41

Continue. 42

Now what continue does is it moves the control on top of the loop again. 43

So that's how you use break and continue in a while loop. 44

Both ways are correct but I do find this more readable.

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