Learn how to comment multiple lines in python and python comment syntax with example. Python does have a multiline string/comment syntax in the sense that ... Python tip: You can use multi-line strings as multi-line comments. Writing comment is important in the programming language. Python comment is used to explain the code and used to prevent execution while testing the code. Python comments used as single line python comment. Here we have shown how to comment multiple lines in python language.
Creating comments in python:-
e.g:
“””This is multiline comment which can be in more than one line”””
Print (“Hello”)
O/p:
Hello
The above example shows that the comment written in triple quotation is ignored.
Two ways of multiline comments:-
Manny single line comment are used to run the block
Writing real comment that span across multiple lines.
It is supported and preferred by python PEP style guide because comments are ignored by python interpreter.
In spite of writing comment in quotation you can write in # in front of each line.
e.g.
#Multiline commenting way
#in python
If you have paragraphs in comment you can write as follows
e.g.
#multiple commenting way
#
#in python
It string should begin with capital letters and end with period.
Docstrings are used as multiline comment by programmers.
There is scientific difference between comments and docstrings.
Comments in python are ignored while Docstrings used inside python function can be accessed at runtime.
DocString can be accessed by “_doc_ “method or help function.