You can use triple-quoted strings. When they're not a docstring (the first thing in a class/function/module), they are ignored.

'''
This is a multiline
comment.
'''

(Make sure to indent the leading ''' appropriately to avoid an IndentationError.)

Guido van Rossum (creator of Python) tweeted this as a "pro tip".

However, Python's style guide, PEP8, favors using consecutive single-line comments, like this:

# This is a multiline
# comment.

...and this is also what you'll find in many projects. Text editors usually have a shortcut to do this easily.

Answer from Petr Viktorin on Stack Overflow
Top answer
1 of 16
2237

You can use triple-quoted strings. When they're not a docstring (the first thing in a class/function/module), they are ignored.

'''
This is a multiline
comment.
'''

(Make sure to indent the leading ''' appropriately to avoid an IndentationError.)

Guido van Rossum (creator of Python) tweeted this as a "pro tip".

However, Python's style guide, PEP8, favors using consecutive single-line comments, like this:

# This is a multiline
# comment.

...and this is also what you'll find in many projects. Text editors usually have a shortcut to do this easily.

2 of 16
112

Python does have a multiline string/comment syntax in the sense that unless used as docstrings, multiline strings generate no bytecode -- just like #-prepended comments. In effect, it acts exactly like a comment.

On the other hand, if you say this behavior must be documented in the official documentation to be a true comment syntax, then yes, you would be right to say it is not guaranteed as part of the language specification.

In any case, your text editor should also be able to easily comment-out a selected region (by placing a # in front of each line individually). If not, switch to a text editor that does.

Programming in Python without certain text editing features can be a painful experience. Finding the right editor (and knowing how to use it) can make a big difference in how the Python programming experience is perceived.

Not only should the text editor be able to comment-out selected regions, it should also be able to shift blocks of code to the left and right easily, and it should automatically place the cursor at the current indentation level when you press Enter. Code folding can also be useful.


To protect against link decay, here is the content of Guido van Rossum's tweet:

@BSUCSClub Python tip: You can use multi-line strings as multi-line comments. Unless used as docstrings, they generate no code! :-)

🌐
GeeksforGeeks
geeksforgeeks.org › python › multiline-comments-in-python
Multiline Comments in Python - GeeksforGeeks
August 14, 2025 - Using multiple # symbols on separate lines is the most efficient and Pythonic way to write multiline comments. ... # This is a multiline comment # Each line starts with # # This method is efficient and preferred print("Geeks For Geeks") # Inline ...
Discussions

How to comment multiple lines in python?
Hi, i need to know how to comment multiple lines in python More on discuss.python.org
🌐 discuss.python.org
1
0
December 31, 2020
"#:" to denote a multiline comment?
# comment goes here # more comment here There you go More on reddit.com
🌐 r/Python
26
0
May 17, 2023
Multiple line comments?
I'll often just wrap it in triple quotes if I'm trying to comment a section out for a little bit. Something like: do_this_line() """ do_not_do_this() nor_this() """ do_this_one_though() More on reddit.com
🌐 r/learnpython
13
1
January 26, 2022
When is it Appropriate to Write Comments/Multiline Comments?
There's quote somewhere I always think about when commenting my code blocks: "Code exists to explain commentary to the computer" More on reddit.com
🌐 r/learnpython
20
8
July 3, 2024
People also ask

What is the difference between a multiline string and a multiline comment?
The difference between a multiline string and a multiline comment lies in their purpose and treatment by the Python interpreter. Multiline strings are enclosed within triple quotes and are treated as regular strings in Python, while multiline comments, created by consecutive single-line comments or multiline strings, are ignored by the interpreter and serve as documentation or temporary code exclusion.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › your ultimate python tutorial for beginners › what is a multiline comment in python?
Multiline Comment in Python [Made Easy]
How to comment out multiple lines in Python?
To comment out multiple lines in Python, you can use triple-quoted strings (''' or " ") if not assigned to a variable or use the hash (#) symbol at the beginning of each line. The backslash (\) method can also be used to indicate line continuation, though it's less common. Most developers prefer triple-quoted strings or multiple single-line comments for clarity.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › your ultimate python tutorial for beginners › what is a multiline comment in python?
Multiline Comment in Python [Made Easy]
How do I uncomment multiple lines in Python?
To uncomment multiple lines in Python, you simply need to remove the comment indicator (hash symbol, #) from the beginning of each line. Uncommenting allows the previously commented lines to be executed again.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › your ultimate python tutorial for beginners › what is a multiline comment in python?
Multiline Comment in Python [Made Easy]
🌐
W3Schools
w3schools.com › python › python_comments.asp
Python Comments
... A comment does not have to ... #print("Hello, World!") print("Cheers, Mate!") Try it Yourself » · Python does not really have a syntax for multiline comments....
🌐
Mimo
mimo.org › glossary › python › multiline-comment
Python Multiline Comment: Syntax, Techniques, and Best Practices
Unlike single-line comments, which use the # symbol, multiline comments require either multiple # symbols or a workaround involving triple-quoted strings. Since Python doesn’t have an official multiline comment syntax, the term typically refers to one of these methods:
🌐
Analytics Vidhya
analyticsvidhya.com › home › what is a multiline comment in python?
What is a Multiline Comment in Python?
November 28, 2024 - A multiline comment in Python is a commenting system used to write comment on multiple lines of code to explain or give details about algorithms, or even use in the process of manipulating code during debugging.
🌐
Simplilearn
simplilearn.com › home › resources › software development › your ultimate python tutorial for beginners › what is a multiline comment in python?
Multiline Comment in Python [Made Easy]
July 31, 2025 - Unlock the power of Python: Master multiline comments and take your coding to the next level! Learn multiline comment in Python in 3 simple steps. Read more!
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Find elsewhere
🌐
Kochiva
kochiva.com › home › what is multi line comment line in python?
what is Multiline comment in Python? - Complete Information
August 13, 2026 - Unlike other languages, Python has no clear syntax for writing multiline comments. To write multiline comment in Python, you can either use # at the start of each sentence or enclose the entire block of text within triple quotes.
🌐
Processing
py.processing.org › reference › multilinecomment
''' ''' (multiline comment) \ Language (API)
Python Mode for Processing extends the Processing Development Environment with the Python programming language.
🌐
W3Schools
w3schools.com › python › gloss_python_multi_line_comments.asp
Python Multiline Comments
Python Examples Python Compiler ... Python Study Plan Python Interview Q&A Python Training ... Python does not really have a syntax for multiline comments....
🌐
Scaler
scaler.com › home › topics › python › what is multiline comment in python?
What is Multiline Comment in Python? - Scaler Topics
October 13, 2022 - Usually, it includes the details ... the program's output but greatly improves its readability. Unlike most programming languages, Python does not support multiline comments....
🌐
Medium
medium.com › @pies052022 › multiple-line-comment-in-python-with-best-examples-1c09048652cf
Multiple-line Comment in Python with Best Examples | by JOKEN VILLANUEVA | Medium
February 28, 2026 - Multiple-Line Comment. In Python, you can comment out more than one line by putting a hash (#) in front of each line.
🌐
Python Morsels
pythonmorsels.com › multiline-comments
Multiline comments in Python - Python Morsels
July 18, 2026 - Python does not have multiline comments. But you can use alternatives like docstrings, editor shortcuts, and conventional commenting methods, depending on your requirements.
🌐
dbader.org
dbader.org › blog › python-multiline-comment
Python Multi-line Comments: Your Two Best Options – dbader.org
December 12, 2017 - """ This is a "block comment" in Python, made out of a mult-line string constant. This actually works quite well! """ answer = 42 · As you can see, you can use triple-quoted strings to create something that resembles a multiline comment in Python. You just need to make sure you indent the first """ correctly, otherwise you’ll get a SyntaxError.
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › python › python multiline comments
Python Multiline Comments: Comment Multiple Lines with # and Triple Quotes
June 21, 2026 - Python has no /* */-style multiline comment: use # on each line, optionally via your editor’s toggle. Triple quotes always define strings; when they are the first statement of a module, class, or function they become docstrings in __doc__.
🌐
iO Flood
ioflood.com › blog › python-multiline-comment
Python Multiline Comment | Easy to Use Methods
August 13, 2024 - This feature is especially useful when you need to provide detailed explanations or deactivate specific lines of code. To write a multiline comment in Python, you simply need to enclose your text within triple quotes.
🌐
Mimo
mimo.org › glossary › python › comment
Python Comment: Master Code Documentation, Learn How to Use Comments in Python
To create a multiline comment in Python, you can use multiple single-line comments or a triple-quoted string using ''' or """.
🌐
Intellipaat
intellipaat.com › home › blog › multiline comments in python
Multiline Comments in Python - Intellipaat
October 29, 2025 - In Python, comments are an important aspect of code that is responsible for clarifying complex logic, documenting changes, and disabling code temporarily during debugging. Unlike some programming languages, Python does not have a built-in syntax for multiline comments.