Comments

Writing Comments in Python

Comments are notes you write in your code to explain what it does. Python ignores comments when running your program — they're just for humans reading the code.
python
# This is a single-line comment
print("Hello!")  # This is an inline comment
Single-line comments start with #. Everything after the # on that line is ignored by Python.

Multi-line Comments

Python doesn't have a dedicated multi-line comment syntax, but you can use triple quotes """...""" or multiple # lines.
python
"""
This is a multi-line comment
(technically a string that's not assigned)
"""

# You can also use
# multiple single-line
# comments like this

Tip:Good comments explain WHY you did something, not WHAT the code does. The code itself should be clear enough to show what it does.

PlaygroundPython
Output
Click "Run" to see output

💬 Got questions? Ask me anything!