Hello and welcome to this video.
Indentation and Pi tone is used to separate or section off parts of a block of code by Tom.
Unlike other languages does not use semicolons or curly braces to indent code pi.
Tom uses white spaces to separate code blocks so as to indent the parts of the code so indentation in
Python is very important indentation in Python can be created using tabs or spaces.
However it is recommended that you use spaces and not tab to intent.
And when you do use spaces for indentation make sure that they are four spaces you could be more but
it is recommended to indent using four spaces so also advisable not to mix the indentation.
So don't indent with spaces and also indent with tabs that will confuse python.
So I would recommend you stick to using spaces to indent your code inside my text editor.
I'm what a python file which is this file here on my desktop.
This is the content of the file so you can see here the print statements are all on the same line which
is OK so if I run this block of code inside my terminal on the bottom here.
So I just need to do call the application by his name so I do my up dot P Way.
If you are on a Mac you need to type in Python 3 followed by the name of the python file before you
can run it.
Now you can see here the content of the file has been output it in my console here.
Now these lines of code as it is is proper properly indented so indentation.
If I wanted to for example if I should then that just do that.
This and I tried to run this file again.
It will fail because the indentation is out of line is not appropriate.
So let me go to my terminal and run again.
I expect to get an error.
You can see here tells me gives me that they print told me where the error is which is this online too.
You can see that says silence is true friend which is this one says telling me that the indentation
is not correct.
So once the indentation is wrong it does not run the code.
This is very important when you are writing several lines of code to make sure that it is properly indented
okay because these are all single line statements.
They have to be on the same line.
So that's why the indentation is important.
If you had several block of code in different sections you used indentation to separate the sections
of the code so that each block belongs to a certain section with single line.
Comments like these is OK because it's just print statement and they all should be on the same lines
because they are not part of a block.
They are independent so they have to be on the same line.
If you try to shift them like I did on this one it you know it impacts because it means indentation
is not correct and therefore gives you an error in the application.
So that's basically how indentation works so is very important in Python.
Thanks for watching and bye for now.