Saturday, 10 October 2026
PastThree rungs, one idea. Solving rung 1 counts. Climb as far as you can.
Putting Words Together
strings + joining with spaces
One space between each
Write a function called join_words
Return one string made of every word in the list with a single space between them, so ["cat", "dog"] gives "cat dog". There is no space at the start or the end. An empty list returns an empty string.
Examples
| Input | Output |
|---|---|
| ["cat", "dog"] | "cat dog" |
| [] | "" |
| ["one"] | "one" |
| ["a", "b", "c"] | "a b c" |
There are extra hidden tests, so make it work in general, not just for these.
Clean them up first
Write a function called tidy_line
The words may have extra spaces around them, and some may be nothing but spaces. Take the spaces off both ends of each word, throw away any word that is left with nothing, then join what remains with single spaces. [" cat ", " ", "dog"] gives "cat dog". If nothing survives, return an empty string.
Examples
| Input | Output |
|---|---|
| [" cat ", " ", "dog"] | "cat dog" |
| [] | "" |
| [" "] | "" |
| [" one "] | "one" |
There are extra hidden tests, so make it work in general, not just for these.
Fit them into lines
Write a function called wrap_words
Put the words into lines that are never longer than limit characters, counting the single spaces between words. Fill each line with as many words as fit before starting the next one, and keep the words in order. No word is ever longer than limit on its own. An empty list returns an empty list.
Examples
| Input | Output |
|---|---|
| ["aa", "bb", "cc"], 5 | ["aa bb", "cc"] |
| [], 5 | [] |
| ["aa"], 5 | ["aa"] |
| ["a", "b", "c"], 1 | ["a", "b", "c"] |
There are extra hidden tests, so make it work in general, not just for these.
Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.