Indentation in Python

Indentation It refers to the (spaces and tabs) that are used at the beginning of a statement.
It is used to create groups/blocks/compound statements in python.
The statements with the same indentation belong to the same group/block.

Block / Compound Statement It is a group of statements (piece of python program text) executed as a unit.
The following are blocks:
1) a module
2) a function body
3) a class definition
4) each command typed interactively is a block.
5) if block
6) else block
7) for block
8) while block

Compound statements are written as
compound statement header:
indented body consisting of statements
may be a single statement or a group of statements.


1) First line of compound statement is header which contains a colon (:) at the end.
2) Contained Statements are not written in the same column as the control statement, rather they are indented to the right side and together they are called a block.

For Example

a=int(input("enter any number"))
print("You have entered" , a)
if a==9467863365 :
    print("Contact for Math & Computers at", a)                   #indentation
    print("Gargs Academy")                                        #indentation
    print("Sonipat")                                              #indentation
else :
    print("You have got wrong number")                            #indentation
    print("Visit site www.gargsacademy.com to get contact no")    #indentation

Output 1:

enter any number9467863365
You have entered 9467863365
Contact for Math & Computers at 9467863365
Gargs Academy
Sonipat

Output 2:

enter any number653542
You have entered 653542
You have got wrong number
Visit site www.gargsacademy.com to get contact no
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.