🐸

The Dusty Note

The Data Tinkererpython-data-tinkerer-01-the-dusty-note
Reward: 70 XP
|

The Dusty Note

Hoppy pushes open the little wooden door of the string workshop and finds a glowing note inside an old drawer. The words are not broken. The edges are simply clogged with dusty blank space, as if the spell is muffled around the sides.

In this workshop, the first move does not need to be a grand spell. Help Hoppy brush the text edges clean so the real clue can show through, and the rest of the adventure becomes easier to follow.

Make the dusty edges show up

Spaces at the beginning and end like to hide, so we wrap the note in square brackets first. That makes the extra empty room visible.

dusty_word = "   lantern   "

print("Before:", "[" + dusty_word + "]")

clean_word = dusty_word.strip()

print("After:", "[" + clean_word + "]")

Look inside the brackets: the first line still has padded edges, and the second line does not. That visible before-and-after moment is the whole point of this lesson.

A light cleanup move: strip()

Python has a very small move for removing extra whitespace from the start and end of a string. That move is called strip().

Later, whenever a fresh piece of text lands in your hands, try asking: are the edges clean already, or should I brush them first? Very often, that is the right opening move.

1
Find the line to fix

The starter already shows a before view and an after view. The line you need to change is the one that creates clean_note.

2
Use strip() to brush off the extra edges

Replace the placeholder with the real cleanup move so clean_note becomes a new string without the extra spaces at the start and end.

3
Run it and compare the two lines

Watch the square brackets when you run the code again. The first line should still look dusty. The second line should look clean.

Why the brackets?

Spaces are sneaky. Without the brackets, this lesson can feel like “nothing changed.” The brackets turn the hidden empty edges into something you can actually see.

Suggested Solution
Expand
Solution:
dusty_note = "   Meet me by the mossy gate   "

print("Before:", "[" + dusty_note + "]")

clean_note = dusty_note.strip()

print("After:", "[" + clean_note + "]")
Advanced Tips
Want more? Click to expand

Programmers call this “trimming leading and trailing whitespace.” You only need the name lightly for now. The habit matters more: when fresh text shows up, check whether the edges need a quick cleanup.

This is the opening posture for the whole workshop. We will keep working with strings, and a lot of that work starts by making the text tidy enough to handle.

Loading...
Terminal
Terminal
Ready to run...