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
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 this lecture I would like to clarify the use of white space so when to use one white space, 1
when to use more than one, 2
and when not to use whitespace, and to explain that to you I've got a script here with three parts. 3
Each of the parts will do the same thing. 4
So the first one prints out a, aa, and three a's, and then b here, and then c. 5
So the first one here I typed in one, two, three, four, five, six. Six spaces. 6
So that will work. 7
As you can see here you get the output correctly but it's not a good practice. 8
Even though that will work it's not a good practice because the code is not very readable. 9
So that's a problem with this first block. And here in the second block 10
I fixed that so the space here is just right. 11
Basically you you want to separate things with spaces. When it comes to operators such as the comparison 12
operators or plus or minus or a multiplication 13
the code will work even if you don't have any spaces like that. 14
However to make the code more readable it's better to have some spaces between operators as well. 15
So the space between if and a number is a must. 16
If you have that the code will not work. 17
You will get an invalid syntax. 18
However no space between operators is fine so that's the problem in this block here that you have these expression 19
without spaces, in some particular cases like sometimes I don't use spaces in the videos because I want 20
to show you the text in a greater font so I have to sacrifice with less spaces so that I can fit more 21
text in a screen. 22
So unless you have a good reason to do so please use spaces, one space, and then here that is fine. 23
So one space here, one here, and one there, and then after the colon. 24
So this is what you should know. 25
And I told you already about indentation, after a colon you all this have indentation, indentation means 26
at least one space. 27
So this would also work like that. 28
But a good practice is to have four spaces, four. 29
So that's correct. 30
And when you have more code in your script it's good to separate things with a break line, so to separate logic. 31
So if you have a conditional block there you have to write them line by line no brake lines here 32
like that. 33
That would also work. 34
But please don't use brake lights to make your code more readable however once the conditional block ends, 35
you have another logical block. 36
There's no clear cut rules here but just user logic. 37
So I thought it's good to have these print functions without brake line between them. 38
So here if I would add another function would make a brake line and then create a function here and 39
so on. 40
And of course use indentation for functions as well. 41
So after the colon always comes the indentation, an that's it more or less about spaces whitespace in 42
Python.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.