Python Comments

  • Comments is  used to explain Python code.

  • Comments is used to make the code more readable.

  • Comments is used to prevent execution when testing code.

Python Support two types of comments:

  • Single line comments

  • Multiline comments

 

Single-Line Comments

 

In python Single Line Comments can be done using the hash (#) symbol at the beginning of the line.

Like –

>>>a = 5  # this is my comment

#print("Hello, Codersarts")
print("Hello, Codersarts!")

Multi-Line Comments

Multiline comments are done using delimiter (“””) at the start and end of lines.

Like that –

#This is a multi line  comment

#written in
#more than just one line
print("Hello, World!")

OR

"""

This is a multi line  comment

written in
more than just one line

"""

print("Hello, World!")

Thanks for reading this, if you have any doubt please do the comments so we can make changes if anything’s is missing.

In the next tutorial, we will learn about “python variables