Question #6531   Submitted by Answiki on 09/02/2022 at 08:04:29 PM UTC

What is the syntax of comments in Python?

Answer   Submitted by Answiki on 09/02/2022 at 08:07:22 PM UTC

There are two syntaxes to insert comments in Python code:


  • The # character allows you to write a comment on a single line:

# This line is a comment
print ("Example of single line comment")


  • Three consecutive double quotation marks """ are used to mark the beginning and end of a comment on several lines:

"""
This is an example
of comment on several
lines
"""
print ("Example of multi-line comment")

Check these example on repl.it.

2 events in history
Answer by Answiki on 09/02/2022 at 08:07:22 PM

There are two syntaxes to insert comments in Python code:


  • The # character allows you to write a comment on a single line:

# This line is a comment
print ("Example of single line comment")


  • Three consecutive double quotation marks """ are used to mark the beginning and end of a comment on several lines:

"""
This is an example
of comment on several
lines
"""
print ("Example of multi-line comment")

Check these example on repl.it.

Question by Answiki 09/02/2022 at 08:04:29 PM
What is the syntax of comments in Python?
# ID Query URL Count

Icons proudly provided by Friconix.