Python multiline comment

Python does not have a built-in mechanism for multi-line comments. To comment out multiple lines in Python, you can comment out each line in a block by adding a pound sign "#" in front of each line. Many Python IDEs have shortcuts for such operations. A popular workaround for creating multi-line comments in Python is to use docstrings. If you use the docstring to comment multiple lines of code in Python, that block of code will be ignored and only lines outside the docstring will be executed. But this option is not recommended because, unlike single-line comments, where the interpreter ignores the comment line, the docstrings are not deleted and take up system resources. Click Execute to run Python Multiline Comment Example online and see the result.
Loading...