![code blocks python code blocks python](https://image.slidesharecdn.com/pythonprogrammingessentials-m6-codeblocksandindentation-140819043157-phpapp02/95/python-programming-essentials-m6-code-blocks-and-indentation-7-1024.jpg)
""" Use * for multiplication of a number """Īs you can see, we have used triple-quoted strings to create something that resembles a multiline comment in Python. A one-line docstring in Python begins with triple quotes (“” “) and also ends with triple quotes ( “””). To print the value, use the print() functionĪ one-line docstring fits into one line. The * is a multiplication operator in Python We will use multi-line docstrings to create a block comment. Python provides two kinds of docstrings: one-line docstrings and multi-line docstrings. If you are commenting things out temporarily, it is fine as a temporary measure. Although it has a similar effect, this is used for documentation strings, not block comments. Using Multi-line Strings as CommentsĪnother way to create multi-line comments in Python is to use multi-line strings or docstrings. So, to add a multiline comment, you could insert a # for each line. # To print the value, use the print() function # The * is a multiplication operator in Python
![code blocks python code blocks python](https://i.stack.imgur.com/FwqyW.jpg)
CODE BLOCKS PYTHON CODE
Unfortunately, Python doesn’t support proper multiline comments because it takes more effort to comment out multiple code lines. To comment on multiple lines of code in Python, use the consecutive single-line comments using #. If you work with Java or C, C++, you can write the following for multi-line codes. Start every line with # sign consecutively, and you will achieve multi-line comments. That means writing consecutive single-line comments. To write multi-line comments in Python, prepend a # to each line to block comments. Python does not have any built-in mechanism for writing multi-line comments.
![code blocks python code blocks python](https://wiki.codeblocks.org/images/3/39/DWCB_watches_01.png)
If you put the comment at the end of the line, then the Python interpreter executes the content before the comment, ignoring it after the comment. You will have an inline comment when you place a comment on the same line as a statement. The # works with only a single line of code and not multi-lines of code. We commented on the code using the # sign in the above example. Comments start with a #, and the Python compiler will ignore its execution.