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:

single and multiline comment in python 1

Python ignores the line that starts with symbol #

Output:

Hello
10

 

Example of Multiline comment in python:

single and multiline comment in python 2

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

Output:

Hello

 

previous small single line multiline comment in python                                                                                                           next small single line multiline comment in python

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    View all posts