comment

single and multiline comment in python

In this tutorial we will learn how to create a single and multiline comment in python. single line comment in python uses symbol # and multi line comment in python uses three single quotes (”’) lets see an example of each.

Single line comment in python:

Comment explaining the code within single line is called single line comment. Single line comment in python should start with symbol #

Multiline (multiple line) comment in python:

Comment explaining the code more than one line is called multiline comment (multiple line comment). Multiline comment in python should be enclosed with in three single quotes (‘ ’ ’)

Example of Single line comment in python:

# This is a single line comment
print('Hello')
# Hello

# this is a single line comment
n=10
print(n)

# 10

Python ignores the line that starts with symbol #

Example of Multiline comment in python:

''' This is a mltiline comment
which can be extendedd more than
one line '''
print('Hello')

# Hello

Python Ignores the multiline comment that is enclosed with in three single quotes (‘ ’ ’)

Last updated