Python Comments

Comments are an integral part of programming.

There are three different ways to write Python comments, documentation strings (docstrings for short), inline comments, and block comments.

Block Comments

Step 1 : Block and inline comments start with a pound sign, #. A block comment comes in the line before the statement it annotates and is placed at the same indentation level:

Inline Comments

Step 2 : Inline comments are placed on the same line as the statement it annotates:

Documentation Strings

Step 3 : A documentation string, or docstring for short, is a literal string used as a Python comment. It is written and wrapped within triple quotation marks; """ or '''. Docstrings are often used to document modules, functions, and class definitions. The following is an example module that's been documented with a docstring. Module docstrings should be put at the beginning of the file:

Step 4 : you can also use docstrings to write multiline comments: