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 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.