[Python] Commenting Out Multiple Lines
- 1 day ago
- 1 min read
Writing comments across multiple lines is needed for annotating source code, and for temporarily disabling processing during development and testing.
Commenting out a single line
To comment out just one line, use "#" (hash)
print("Good morning!")
# print("This line is commented out and will not run")
print("Good afternoon!") #You can also put a comment after a command
print("Good night!")The result is as follows. The commented-out part doesn't run, so it isn't printed.
Good morning!
Good afternoon!
Good night!
Commenting out multiple lines
To comment out multiple lines, wrap the target code in triple quotes. Triple quotes can be either """ (three double quotation marks) or ''' (three single quotation marks).
print("Good morning!")
'''
print("This line is commented out and will not run")
print("Good afternoon!") #You can also put a comment after a command
'''
print("Good night!")The result is as follows. The commented-out part doesn't run, so it isn't printed.
Good morning!
Good night!![[Deadline July 30, 2026] Several AWS Services Stop Accepting New Customers — The Full List and What to Check Now](https://static.wixstatic.com/media/5b7c68_472f115efd5641649ea3e9621d5d46b6~mv2.png/v1/fill/w_980,h_547,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/5b7c68_472f115efd5641649ea3e9621d5d46b6~mv2.png)


Comments