Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How do we create multiline comments in Python?

How do we create multiline comments in Python? What syntax is used in Python do comment a block of statements in a Python script?


1 Answer
Pythonic

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")

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.