Getting Started with Python

Python Comments

Comments in Python 💬

Comments help you explain your code. Python ignores them when running.

Single-Line Comments

Use

#
for single-line comments:

# This is a comment
print("Hello!")  # This prints a greeting

Multi-Line Comments

Use triple quotes for longer explanations:

"""
This is a multi-line comment.
It can span several lines.
Great for documentation!
"""

Pro Tip: Write comments to explain why you're doing something, not just what the code does.

python
Loading...
Output
Run execution to see output...