Python Comments

Share Your Love

Comments are used to explain the code means it clears which line of code is written for which purposes.

In python comments are used for in-line code documentation.

The comments are make more code readable.

The comments are not for execution purposes it only documentation purpose.

Creating a Comment:

Comments are starting in python with #, the python interpreter ignores them.

Example Of Comment:

#This is a comment
print("Hello, World!")

The comment can be placed at the end of each line of code means,

print("This is python terminal.") # this is a print Statement.

By giving the comment it is very easy understand the code and python interpreter not take as importance the comment line of code.

Multiline Comments:

If we write more than one lines in python comments we are using multiline comments.

So, writing # multiple times we write multiline comments, Example:

#This is first-line comment
#This is second-line comment
#this is third-line comment
print("The multi line Comment.")

Or, write triple quote for multiline comment also like,

This is a comment
written in
more than just one line
print("Hello, World!")

The above code the comments are written within string but it works as comment not string because it doesn’t assign to any variable so work as multiline comment.

Share Your Love
Avatar photo
Lingaraj Senapati

Hey There! I am Lingaraj Senapati, the Founder of My skills are Freelance, Web Developer & Designer, Corporate Trainer, Digital Marketer & Youtuber.

Articles: 429

Newsletter Updates

Enter your email address below to subscribe to our newsletter