[Python] Commenting Out Multiple Lines
Jul 20
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!![[September 2026] AI & IT News Roundup for SMBs|6 Handpicked Stories](https://static.wixstatic.com/media/5b7c68_147333112cfc4639a957819174666aea~mv2.png/v1/fill/w_980,h_515,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/5b7c68_147333112cfc4639a957819174666aea~mv2.png)


Comments