How to Use Comments In Python

“Comments In Python”: In This article or tutorial we will learn, how to write/use comments in Python code. Comments are simple text lines which we use in our source code & these comments/text lines don’t effect to our program/source code.
Comments explain and make easily readable a python source code, we can easily understand a complicated code later with the help of comments. It is very important to understand everything about code that’s why we use comments
We can create python comments  by using hash (#) syntax in beginning of the comment line in . See the following example to understand

Example 1


In this upper example 1, you can see line 1 is a comment line.
You can also place a comment in the end of the line and Python will ignore it. See below an example

Example 2



Multiline Python Comments

Python programming language has not specific keyword or syntax for multiline comments. For multiline comments we can insert hash # for each line in python.
Actually, Python don’t offer multiline comments but python ignores string literals that are not assigned to a variable. So, we can add multi-line string/comment in python code by using triple quotes(“””). See the following example to understand

Example 3


In upper example 3, you can see the python ignores the text/string which is not assigned to a variable.
See another example. In this example we will use hash # for each line in python.

Example 4



Get More Python Tutorials