Comments in Python programming language

Comments in Python programming language

Comments are used to explain programming code in any language for the same purpose comments are also used in the python programming language. It can also be used to hide the code as well.

Comments are the most helpful part for programmers to understand the purpose of any program. It enables us to understand the way, a program works. In python, Comments are started with # symbol see example below. The interpreter ignores the comments.

#this is single line comments

''''' this is


Comments ''''' 

Comments is not a part of the program, but it enhances the interactivity of the program and makes the program readable.

Python supports two types of comments:

1) Single Line Comment:

If programmer wants to write a single line comment, then comment must start with #


# This is single line comment.  

print "Hello Python"  


Hello Python

2) Multi Line Comment:

If a programmer wants to write multiline comment then it must be starts from triple quotes and ends with triple quotes.


1.      ''''' This 

2.          Is 

3.          Multiline comment'''  


1.      #single line comment  

2.      print "Hello Python"  

3.      '''''This is 

4.      multiline comment'''’’’  



Hello Python

Enjoyed this article? Stay informed by joining our newsletter!


You must be logged in to post a comment.

Related Articles
About Author