Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
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
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.