Block Comment

Block comments in Python usually refer to the code following them and are intended to the same level as that code. Each line of block comment starts with a ‘#’ symbol.

Syntax:

# This is a block comment 
# Each line of a block comment is intended to the same level

Example:

Python3




def my_fun(i):
   
    # prints GFG on the console until i
    # is greater than zero dercrements i
    # by one on each iteration
    while i > 0:
        print("GFG")
        i = i-1
 
 
# calling my_fun
# it will print GFG 5 times on the console
my_fun(5)


Output:

GFG
GFG
GFG
GFG
GFG

How do we create multiline comments in Python?

Comments are pieces of information present in the middle of code that allows a developer to explain his work to other developers. They make the code more readable and hence easier to debug. 

Similar Reads

Inline Comment

An inline comment is a single line comment and is on the same line as a statement. They are created by putting a ‘#’ symbol before the text....

Block Comment

...

Docstrings

Block comments in Python usually refer to the code following them and are intended to the same level as that code. Each line of block comment starts with a ‘#’ symbol....