Beginner Fundamentals

Comments

Comments explain code and are ignored when running.

Single line

Start with #:

# this is a comment
print("hi")  # comment at the end of a line

Multiple lines

Python has no dedicated block-comment syntax. Use # on each line:

# line 1
# line 2
# line 3

Or a multi-line string (technically not a comment, but ignored if not assigned):

"""
This works as a
block comment.
"""

Comment out code to disable it

# print("won't run")
print("runs")