When we write our code it is very important to make sure that our code can be easily understood by other programmers. Commands are used to explain our code, which will increase the readability of our code. Commands are also used to prevent the execution of code.
In other programming languages like C, C++, and Java, it provides single-line comment and multi-line comment but python provides only single-line comment.
In python, comments start with a hash(#) at the beginning of the statement or code. Python will ignore everything after the hash(#) up to the end of the statement or code.
#This is an example for comment print("Hello World")
Python does not have any syntax for multi-line comments, but there are two ways to create multi-line comments in python,
We can use hash(#) at the beginning of each line of code to create a multi-line comments.
#This is an #Example for #multi-line comments print("Example for multi-line comment")
The other way of creating multi-line comments is by using triple quotes.
Note: Python will ignore strings that are not assigned to a variable.
""" This is an another example for Multi-line comments """ print("Hello Python")
Get real time update about this post categories directly on your device, subscribe now.