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
bg Bulgarian Download
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:00,450 --> 00:00:05,720 In the previous video we built this code. The code goes like this. 1 2 00:00:05,810 --> 00:00:13,580 We assign the empty string to user name variable, and then we build a while loop which checks if this 2 3 00:00:13,580 --> 00:00:14,930 condition is true. 3 4 00:00:15,170 --> 00:00:20,020 So if the condition of that user name is different from pypy. 4 5 00:00:20,420 --> 00:00:25,460 If user name is different from pypy, this is going to be executed. 5 6 00:00:25,520 --> 00:00:30,410 So in the first iteration user name is actually different from pypy because user name is an empty 6 7 00:00:30,410 --> 00:00:31,270 string. 7 8 00:00:31,280 --> 00:00:33,970 Therefore this is going to be executed. 8 9 00:00:34,010 --> 00:00:42,980 The program asks for the user name. If the input is a for example a will be assigned to user name and 9 10 00:00:42,980 --> 00:00:44,650 then the second iterations starts. 10 11 00:00:44,640 --> 00:00:50,540 So while A is different from pypy which is true, this is going to be executed again. 11 12 00:00:50,570 --> 00:00:54,110 That's why we get these prompt here again. 12 13 00:00:54,170 --> 00:01:02,480 If you enter pypy, the loop ends because in the third iteration pypy is not different from 13 14 00:01:02,480 --> 00:01:04,820 pypy, so this will not occur anymore. 14 15 00:01:04,820 --> 00:01:12,290 Now there is a different way to do this using a brake statement instead of doing the above. 15 16 00:01:12,320 --> 00:01:12,770 Let me 16 17 00:01:18,290 --> 00:01:19,770 do it another way. 17 18 00:01:19,850 --> 00:01:25,410 Again using the while loop but this time you want to check if true. 18 19 00:01:26,090 --> 00:01:33,460 While true which is always true so the loop will always execute until we break it, so while true 19 20 00:01:33,500 --> 00:01:41,260 we want to ask for the user name, input enter the user name. 20 21 00:01:41,310 --> 00:01:46,020 Now we want to create a conditional here to check inside the while loop. 21 22 00:01:46,100 --> 00:01:55,550 So if user name is pypy, and break the loop. 22 23 00:01:55,970 --> 00:01:59,810 Else continue. 23 24 00:02:00,500 --> 00:02:04,630 Let's see what this will give us Python 3 24 25 00:02:04,750 --> 00:02:05,840 b.py. 25 26 00:02:05,860 --> 00:02:08,550 That's the right side script. 26 27 00:02:08,780 --> 00:02:11,520 Enter username. 27 28 00:02:11,830 --> 00:02:12,260 Nope. 28 29 00:02:12,660 --> 00:02:13,600 Nope. 29 30 00:02:13,620 --> 00:02:14,070 Pypy. 30 31 00:02:14,970 --> 00:02:15,350 Yes. 31 32 00:02:16,870 --> 00:02:17,620 Let me try again. 32 33 00:02:17,650 --> 00:02:21,970 If you enter pypy right away again the loop terminates. 33 34 00:02:23,370 --> 00:02:28,140 I do prefer this actually because it gives you more control of the workflow. 34 35 00:02:28,140 --> 00:02:32,970 So this is what's happened here, while true which is always true. 35 36 00:02:32,970 --> 00:02:39,800 So the first iteration occurs because true is true, and we ask for the user name in the first iteration. 36 37 00:02:39,900 --> 00:02:45,470 So in the first iteration here the user name was asfd. 37 38 00:02:45,660 --> 00:02:54,570 So if asfd is equal to pypy breaks the loop. That is not the case because asfd is different then 38 39 00:02:54,570 --> 00:02:55,280 pypy. 39 40 00:02:55,320 --> 00:03:00,720 Therefore this will not occur because this condition is false. 40 41 00:03:00,720 --> 00:03:02,310 Else will be executed. 41 42 00:03:02,400 --> 00:03:03,600 Continue. 42 43 00:03:03,720 --> 00:03:08,810 Now what continue does is it moves the control on top of the loop again. 43 44 00:03:08,850 --> 00:03:13,080 So that's how you use break and continue in a while loop. 44 45 00:03:13,170 --> 00:03:18,090 Both ways are correct but I do find this more readable. 4086

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