# How do we create multiline comments in Python?

PythonServer Side ProgrammingProgramming

Comment is a piece of text in a computer program that is meant to be a programmer-readable explanation or annotation in the source code and not ignored by compiler/interpreter. In Python script, the symbol # indicates start of comment line.

C like block comment (/* .. */) is not available in Python. If more than one consecutive line are to be commented, # symbol must be put at beginning of each line

##comment1
##comment2
##comment3
print ("Hello World")


A triple quoted multi-line string is also treated as comment if it is not a docstring of a function or class.

'''
comment1
comment2
comment3
'''
print ("Hello World")

Published on 15-Sep-2021 21:49:21
Advertisements