Skip to content

Python Comments

Every programming language having the facility for comments. Python also provides the best commenting system which is used to increase the readability of the code

Types of Comments

1. Single Line Comments
2. Docstring Comments
3. Multiline Comments

Single Line Comments

Use the hash symbol to write a single-line comment

#Single Line Comment
print("I'm print statement with single line comment")

Output

I'm print statement with single line comment

Docstring Comments

We can use multi-line docstring as multiline comments. A multi-line docstring starts with triple quotes (""") and ends with triple quotes (""")

"""The multiline comment
using
Docstring method"""
print("I'm print statement with Docstring comment")

Output

I'm print statement with Docstring comment

Multi Line Comments

Python does not really have a syntax for multi line comments. We should insert # for each line or use the above mentioned Docstring method to add a multi line comments

# The multiline comment
# by inserting hash
# in each line of code
print("I'm print statement with Multiline comment")

Output

I'm print statement with Multiline comment