Understanding indentation is very important in python indentation refers to spaces that are used in the beginning of a statement. The statements with same indentation belong to same group called a suite.
By default python uses four spaces but it can be increased or decreased by the programmers. Consider the statements given below.
Example of Indentation
Hear : If x==1:
Belong to same group as they do not have any spaces before them so, after executing the if statement, python interpreter goes to the next statement i.e print(‘end’) even if the statement “ if x==1 is not executed , interpreter will execute print(‘end’) statement as it is the next executable statement in our program.
In the next level: the following statements are typed with 4 spaces before them and hence they are at the same level(suite).
these statements are inside if x==1 statement hence if the condition is ture is satisfied then the above 3 statement are executed . thus the third statement if y==2 is executed only if x==1 is ture
at the next level we can find the following statement
these two statements are typed total eight spaces before them and hence they belonging to the same group (or suite) since they are inside if y==2 satement they are executed only if condition y==2 is true . hear we are given aexampe with table