Contact US


Get Your Project Done by our experts
info@fundaofwebit.com

Comments in Python

Comments are written to make the code more readable and understandable when someone looks at the code.

Comments can be used write description about the code without disturbing the code execution. The comments are ignored when we run the program.

How to create a comment in Python

We can write Comments in python using a "#" symbol. 

#Here goes your comment
print("Hello world")

A comment can also be written at the end line by writing "#"  at the end.

print("Hello world"#Here goes your comment

Example:

a = 4  + 5 #addition of two numbers
print(a)
How to create a multi-line comment in Python
Python does not have a particular syntax for multi-line comments, but we can write multi-line comments by placing a "#" symbol in the beginning of each line of the comment.

#Here goes your comment and 
#this is also 
#a part of the comment

print("Hello world")

We can also write multi-line comments by putting the comment in between three double quotes ( """ """ ). This is a multi-line string, but as Python does not read a string which is not assigned to any variable, It will act as a multi-line comment.

"""Here goes your comment and 
this is also 
a part of the comment"""

print("Hello world")


© Copyright - 2018 - 2021 | All rights reserved at Funda of Web IT