In programming, comments are the readable texts in the source code which are completely ignored by compiler or interpreter. It helps the programmer to remember what tricky things s(he) did in the block of source code and it also helps others to understand the source code better. Comments can be anything like a description of the logic behind the code, your purpose of the program, Or sometimes in large programs, you can comment on the source code blocks to remember their individual function or purpose. comment in python is most important.
Not only in python but mostly in all programming languages. It is always a good practice to use comments in the code. It makes the source code neater and understandable.
In python hash character(#) is used to write comments. Any line starting from the # is considered as a comment and is ignored by a compiler or interpreter. It doesn’t affect the program.
There are two types of comment in python,
- Single-line comment
These are usually helpful when you want to write the purpose of the code or what it does
- Multi-line comment
These are helpful when you want to write the logic behind the code block/program
In python, single-line comments start from the # and extend till the end of the physical line.
For a multi-line comment, you can start with triple single quote or double quote at start and at end.
This is all about comment in python. Write comment in every code is such a good practice
If you have any questions DM me on Instagram