1. Home
  2. Python
  3. Python Tutorials
  4. Python – Indentation

Python – Indentation

Python Indentation

In Python, The indentation is the white space at the beginning of a line to define scope. Generally the other programming languages uses brackets to defined the scope of a function, loop etc. Python uses indentation instead of brackets for this purpose.

Python Indentation Example

Open a Python terminal and run below example:

a = "Rahul"
def myfun():
    b = "TecAdmin"


In above example, line number 3,4 and 5 have blank spaces before them. This is known as indentation. You can use any number of blank spaces for indentation but the number of spaces must be same for all lines for any scope. As per above example, I have used four blank spaces.

The last line have no blank space in start, It means the function scope is finished now.

Let’s execute above example on on Python terminal:

Python Indentation Example

Tags ,