Video Coming Soon...

Created by Zed A. Shaw Updated 2026-09-08 23:25:25
 

2: Comments and Pound Characters

Comments are very important in your programs. They are used to tell you what something does in English, and they are used to disable parts of your program if you need to remove them temporarily. Here's how you use comments in Python:

View Source file ex2.py Only

# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.

print("I could have code like this.") # and the comment after is ignored

# You can also use a comment to "disable" or comment out code:
# print("This won't run.")

print("This will run.")

From now on, I'm going to write code like this. It is important for you to understand that everything does not have to be literal. If my Jupyter looks a little different from yours, or if I'm using a text editor, the results will be the same. Focus more on the textual output and less on the visual display such as fonts and colors.

Previous Lesson Next Lesson

Register for Learn Python the Hard Way, 5th Edition (2023-2024)

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.