Comment (Python)

A comment is a note in your code that Python ignores when running the program. In Python, anything after a # on a line is a comment.

Python

Comments explain why code does something, for humans reading it. Python has no multi-line comment syntax, but triple-quoted strings are often used for documentation (docstrings).

Syntax

# this is a comment

Examples

Python

# greet the user
print("hello")  # inline comment

Output:

hello

See also

Back to the Dictionary