A well-commented piece of code improves readability. A developer can use comments within the code to explain the code. So, later if some other developer is working on the same code, he can easily understand the code. So, it is always a good piece of advice to use comments within Python code.
In Python, we can use the following syntax for a comment.
# This is a comment x = 19 print(x)
We can also add a comment at the end of a line:
# This is a comment x = 19 # This is another comment print(x)
When the Python interpreter finds a comment starting with ‘#’, it ignores the rest of the line.
Please note that the above examples are examples of single-line comments. But, sometimes a developer needs to write a multiline comment. One can do so easily in one of the following ways.
# This comment # is a multiline # comment x = 19 print(x)
One can also write a multiline comment in the following way:








































0 Comments