PythonServer Side ProgrammingProgramming

A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them.

## Example

Live Demo

#!/usr/bin/python
# First comment
print "Hello, Python!" # second comment

## Output

This produces the following result −

Hello, Python!


You can type a comment on the same line after a statement or expression −

name = "Madisetti" # This is again comment

You can comment multiple lines as follows −

# This is a comment.
# This is a comment, too.
# This is a comment, too.
# I said that already.

Following triple-quoted string is also ignored by Python interpreter and can be used as a multiline comments −

'''
This is a multiline
comment.
'''
Published on 24-Jan-2020 11:20:41