# How do we provide comments in Python?

PythonServer Side ProgrammingProgramming

Comment is a text in a computer program that is a programmer-readable explanation or annotation in the source code. It is ignored by compiler/interpreter.

In Python script, the symbol # indicates start of comment line. It is effective till the end of line in the editor. If # is the first character of line, then entire line is a comment. It can be used in the middle of a line. Text before it is a valid Python expression, while text following it is treated as comment.

#this is a comment
print ("Hello World")
print ("Welcome to TutorialsPoint")    #this is also a comment but after a statement.

In Python, there is no provision to write multi-line comment, or a block comment. Each line should have # symbol at the start to be marked as comment. Many Python IDEs have shortcuts to mark a block of statements as comment.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")
Updated on 01-Oct-2019 11:37:52