How to use comments in Python. Are you Excited? Learn easily in 5 minutes.


Now, questions arise. What are comments in python?

Basically, comments in python are a line that won’t execute in our program. But it tells us what we will be going to perform. In this article, I show how to write comments in Python. Comments in Python, be it in the form of a command-line comment, a comment on a web page, or even in a blog post. Finally, we learn how to use comments in Python to make the program more readable for the person who will read it.

You can also write nested comments by starting with a multi-line comment in a block and then starting a second multi-line comment in the first block.

What are comments in Python?

Comments are very helpful, if another programmer want to edit or complete your code. Comments help programmer to understand about code.

There are two types of comments

1. Single line comment

2. Multi-line comment

1. Single line comment

 “#” symbol is used for single line comment in Python. # is written before the line that you want to make comment. You can use comment anywhere in your code, such as a line of code, a function call, or a command line argument.

Example :  # This is single line comment.

comments in Python

2. Multi-line comment

Triple quotes, i.e (“””) is used for multi-line comment in Python. Triple quotes, i.e (“””) is written before the line. And after the completion of the line. The line, that you want to make comment. You can use comments anywhere in your code.


 “”” this is                               




comments in Python

Output :-

comments in Python

The multi-line comment is not print. It is not executed in the program.

Most of the time I have to add multiline comments to my Python code. Comments in Python 3 are more useful when I am reworking or testing code for a long time, but they can also be more useful when your code has been reworked or tested for a long time.

Comments help you understand why certain blocks of code have been added to your program, and what their purpose is. Comments are not just something to enlarge the lines of code, they enrich your code by their intelligibility. Comments are one of the best ways to make code meaningful, and it’s a great way to improve code by improving and understanding it better.

Comments are special lines of code. Comments are not evaluated by the compiler or interpreter. Comments are wont to execute in our program. Comments are used to simply explain the code in our program. It is used so programmers easily understand the code after some time also.

While it may not be hard for professionals to understand, it can be very helpful for someone who is trying to learn Python to include comments in the code. To understand the comments of a Python 3 program, it is very useful and important for a programmer to explain the program’s operation.

You may also read.

Basic Of Python

  1. […] is used to comments the […]

  2. […] is used to comments the […]

Leave A Reply

Your email address will not be published.