The Broken Sentence
Last time, we brushed the dusty edges off the note. Now the clue glows under the lantern, but it is still sealed as one long ribbon of text: "follow the lantern path".
If Hoppy wants to inspect one word on its own, that whole ribbon gets in the way. This small spell is not about changing the words. It is about splitting the sentence into word pieces so each clue can be seen clearly.
First, watch the shape change
The most important thing in this lesson is not a definition. It is seeing one clear change: a full string can turn into a small backpack of separate pieces.
secret_line = "open the silver gate"
print("Whole sentence:", secret_line)
pieces = secret_line.split()
print("Word list:", pieces)
last_word = pieces[-1]
print("Last word:", last_word)
When you run it, you will see ['follow', 'the', 'lantern', 'path']. That is no longer the original sentence shape. It is a list that you can keep working with.
Use split() to open it up
split() breaks a space-separated sentence into smaller pieces. For this clue, those pieces are the individual words.
Then make one tiny read from that list, like taking the first word out. That way, you do not just see that the sentence changed shape. You prove that the new shape is usable.
Find the line that creates words, and use split() on broken_sentence.
Change first_word so it reads the first item from words.
Look at the whole sentence, the word list, and the first word you pulled out. The sentence is not just one big block anymore.
That is the visual shape of a list. It is Python's way of showing you that you are no longer looking at one string. You are looking at separate pieces.
Suggested SolutionExpandCollapse
broken_sentence = "follow the lantern path"
print("Whole sentence:", broken_sentence)
words = broken_sentence.split()
print("Word list:", words)
first_word = words[0]
print("First word:", first_word)Advanced TipsWant more? Click to expandClick to collapse
Programmers would say that split() uses spaces by default here, and that the result is a list. You only need the names lightly for now. The real win is feeling that one packed sentence can open into separate pieces.
The main habit is enough for now: when a sentence feels too packed to inspect piece by piece, split it first. In the next lesson, Hoppy will use those pieces again in a new way.