All language subtitles for 12. While Loops How and Why

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 So you learn that a for loop iterate through a container which could be a list, or a string, or a tuple. 1

And the loop will terminate when the container is exhausted. 2

So for example it prints out one, two, and three. And when there are no more items 3

the loop ends. 4

So a full loop runs until a container is exhausted and a while loop a while loop runs as long as this 5

condition is true. 6

Let me execute that and see what is going to happen. 7

So you will see that 1 is being printed out all the time. 8

So if I scroll up here I will not be able to find where the starting point was because there's a million 9

ones now being printed out there every split of a second. 10

So what's going on here is that a while loop, while is a keyword, and then that is followed by a condition. 11

In this case the condition is that A is greater than zero which is true. 12

So A is actually 3. 13

That means this condition is true. 14

And as long as this condition is true, this will be printed out, so under the while loop you can have 15

as many actions operations as you want. 16

For example let me interrupt this with control C on your terminal. 17

And then add another line here print2, save, execute. 18

So 1 2, 1 2, 1 2, 1 2, 1 2 19

is being printed out. 20

Okay I'll interrupt that. 21

Not the rate that these numbers are being printed out 22

depends on your computer. 23

Processor speed. 24

So the faster your processor, the faster you will get these action here, 25

these operations being executed. 26

Now of course this will always forever be true because it's a just a static declaration of a variable 27

here. 28

So no one is changing it here, therefore of a condition will always be true. 29

You can see inside Python when you check something like 3 is greater than 0 you get true. 30

So this is basically while True, and you will sometimes see it like that. 31

So just delete the first line. 32

Exit here, execute the code again. 33

So again the same thing happens because true is always true. 34

However, this is not how while loops are used in real world. 35

It's meaningless to check if true is true and print out something all the time. 36

So let me go ahead and explain while loops in a better example in the next video.

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