Python Comments
Python Comments
Comments are essential for any programming language. It provides the readability to our program, and the Python interpreter ignores the commented code.
There are two ways to apply comment in the Python code. It is very good to practice to use comments in the code to make code more understandable. Without using comments, code can be confusing. If we want to highlight any statement of code without executing it, then comment that statement.
A comment is not a part of the code, but it makes code more readable.
Single-line Comment
The single-line comment is created by using # (hash) character at the beginning of the line. It is automatically terminated at the end of the line. For example:
Example-1
#This is a single-line comment in Python
print("Welcome to tutorialandexample")
Output:
Welcome to tutorialandexample
Multiline Comment
Multiline comment can be created inside the triple quotes. For Example:
print("Welcome to tutorialandexample") '''This is the example of multiline comment using the triple quotes. Use in your code'''
Output:
Welcome to tutorialandexample