LEARN Python - 1.5 Comments (#) Secret Messages to Future You - zerotopyhero.com
LEARN Python - 1.5 Comments (#) Secret Messages to Future You - zerotopyhero.com

Learn Python – 1.5: Comments (#): Secret Messages to Future You

Let’s be honest for a second.
You think you’ll remember everything you write in your code.
You really do.
But future you?
Future you is a different creature entirely.

Future you will wake up one day, open your old Python file, stare at a strange piece of logic, and whisper:

“Who wrote this?”

Spoiler: it was you.
And you will have no idea what you were thinking.

That’s where comments come in.

Comments are like tiny messages you sneak into your code; explanations, reminders, warnings, breadcrumbs. They don’t run, they don’t affect your program, and Python ignores them completely. They exist purely for humans.

They’re the quiet little helpers that say:

  • “Hey, this part here? You did it for a reason.”

  • “This variable? It’s not random, trust me.”

  • “This ugly workaround? It was necessary, don’t touch it.”

Comments are your future self’s best friend.
And honestly, they make your code less scary for everyone else too.

Let’s take a look at how they work.

How to Write a Comment

Writing a comment in Python is as easy as hitting the # key.
The moment Python sees that symbol, it stops paying attention to the rest of the line.

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

				
			

Python runs the print("Hello!")
and completely ignores the comment above it.

You can also put a comment at the end of a line:

				
					age = 25  # This explains what the variable means

				
			

Everything before the # runs normally.
Everything after it is pure human text.

That’s really all there is to it.
One little symbol, and boom, you’ve created a note inside your code.

Why Comments Matter

Comments might look tiny and harmless, but they save you (and anyone reading your code) from a world of confusion later.

When you write code, it’s fresh in your mind.
You know why you used that variable name.
You remember what that weird calculation does.
You totally understand why you added that mysterious “temporary fix.”

Fast-forward a week, or even a day, and all that knowledge evaporates.

That’s where comments save the day.

They help you:

  • Explain why something is written the way it is

  • Make tricky logic easier to understand

  • Leave reminders for the future

  • Make your code friendlier for anyone who reads it

  • Avoid the “What was I thinking?” panic

Python ignores comments completely, but humans don’t.
They make your code less like a puzzle and more like a readable story.

A few well-placed comments can turn confusing code into something clear and comforting.

A Good Comment vs a Bad Comment

Not all comments are created equal.
Some are helpful.
Some are… well… just noise.

A good comment explains something that isn’t obvious at first glance, usually why you’re doing something.

				
					# Apply weekend discount
price *= 0.9

				
			

You instantly understand the purpose behind the line.
Clear. Helpful. Future-you approved.

A bad comment simply repeats what the code already says:

				
					price *= 0.9  # multiply price by 0.9

				
			

If you removed that comment, absolutely nothing of value would be lost.

Here’s a quick rule of thumb:

  • If the code explains itself, skip the comment.

  • If the reason isn’t obvious, add a comment.

  • If you’re doing something weird on purpose, comment it.

Great comments don’t narrate the code, they illuminate it.

Multiline Comments

Sometimes you want to leave a longer note, maybe a small explanation, a reminder, or a block of thoughts you don’t want Python to run.
Python doesn’t have an official “multiline comment” feature like some other languages, but developers use a handy trick:

They write a string that isn’t assigned to anything.

				
					"""
This is a longer note
that spans multiple lines.
Python ignores it completely
because it’s not stored anywhere.
"""

				
			

This works because Python sees it as a string… and then realizes no one is using it, so it quietly tosses it aside.

You’ll often see this used for:

  • Longer explanations

  • Temporarily disabling a chunk of code

  • Notes to yourself during development

  • Describing what a file or function is supposed to do

Just don’t overuse it.
If you find yourself writing a mini novel inside your code, it might be a sign that the code needs to be simplified instead.

When Not to Comment

Here’s a little secret: beginners often write too many comments. (Don’t worry if you do, even some seasoned coders do it too, sometimes)
They comment every line like they’re narrating a cooking show:

				
					x = 5     # set x to 5
y = 10    # set y to 10
z = x+y   # add x and y
print(z)  # print z

				
			

This doesn’t make your code clearer, it just makes it busier.

A good rule is this:

If the code is already obvious, don’t comment it.

Comments are most useful when:

  • Something is confusing

  • The purpose isn’t immediately clear

  • You’re doing something clever (or weird) on purpose

  • You’re explaining why something is needed

They’re least useful when:

  • They repeat what the code already says

  • They state the obvious

  • The code is simple enough on its own

Clean code with a few thoughtful comments beats messy code with a comment on every line.

Use them as little signs of guidance, not subtitles.

Let's Wrap Up: Your Future Self Says Thank You

Comments may be tiny, but they play a huge role in keeping your code friendly, not just for others, but especially for future you.
You now know how to drop helpful notes into your programs, explain tricky ideas, and leave breadcrumbs that make your code easier to return to later.

The more your programs grow, the more valuable comments become.
They’re the quiet superheroes of clean, readable code.

Short lesson, big payoff.

Mini Quiz

Try answering these before peeking at anything else:

  1. What symbol do you use to write a comment in Python?

  2. Does a comment change how your program runs?

  3. Which is the better comment?

    • A) price = price * 0.9 # multiply price by 0.9

    • B) # Apply weekend discount

  4. What’s one situation where comments are helpful?

  5. Can you write a comment at the end of a line of code?

  6. What do triple quotes (""" … """) do when used on their own?

  7. Should you comment every single line of code? Why or why not?

Mini Challenge

Write a small program that:

  1. Asks for your name

  2. Greets you

  3. Uses at least three helpful comments explaining what each part of the program is doing

  4. And includes one “just for fun” comment of your choice

Example of a fun comment:
# Hello future me. I hope you slept well.

Keep it simple, the goal is to practice good commenting habits, not to build a huge script.

Mini Challenge Answer

Here’s a perfect beginner-friendly solution:

				
					# Ask the user for their name
name = input("What's your name? ")

# Store the greeting message so it's easy to change later
greeting = f"Nice to meet you, {name}!"

# Print the greeting to the user
print(greeting)

# Just a fun comment for future me
# Dear future me: I hope you remembered to drink water today.

				
			

Another version with slightly different comment styles:

				
					# Get the user's name
name = input("Your name: ")

# Use an f-string to make the greeting friendly and readable
print(f"Hello, {name}!")

# Explain WHY this line exists (not just what it does)
# We're ending the program with a simple goodbye message for clarity
print("Thanks for visiting! Come back soon!")

# Future me... sorry if this code is messy. I'm learning.

				
			

And a slightly more playful option:

				
					# Step 1: ask the user for their name
name = input("Tell me your name: ")

# Step 2: greet them using an f-string
print(f"Welcome, {name}! Glad you're here.")

# Step 3: add a friendly closing message
print("Hope you're having a great day!")

# Secret message to future me:
# If you're reading this, it means the program still works. Nice.

				
			
ZeroToPyHero