To create a block comment in Python, you just need to add # before each line – just like you would for a regular single line comment.
# This is a valid block comment
# Here is some more commentary
# And finally some more information
You can also use triple quotes to create multi-line comment in Python. Triple quotes create a multi-line string in Python.
'''
Here is a block comment with some text in Python
'''
When programming, comments are fundamental to helping make your code readable and helps provide context to components of your code.
One such kind of comment which is useful is the block comment.
Block comments are used to provide descriptions of files, classes, and functions. Block comments are commonly used at the beginning o files and before functions.
To create a block comment in Python, you just need to add # before each line – just like you would for a regular single line comment.
# This is a valid block comment
# Here is some more commentary
# And finally some more information
Another way you can create a block comment is with a multi-line string literal.
While this isn’t true comment, it can work like a comment in your Python code.
You can also use triple quotes to create multi-line comment in Python.
Below shows you how you can create a multi-line string literal in your Python code.
'''
Here is a block comment with some text in Python
'''
Hopefully this article has been useful for you to learn how to create block comments and multi-line comments in your Python code.