Lesson 9 — Write the tests first, then ask
Tests are the best prompt
Instead of describing a function in words, give the assistant the tests it must pass. Tests are exact: there is no way to misunderstand slugify("Hello World") == "hello-world".
The workflow:
- Write the test cases yourself — normal input, messy input, empty input.
- Put them into the prompt.
- Run the assistant's answer against the same tests.
- If something fails, send back the failing case — not "it doesn't work".
A slug is the URL-friendly version of a title: lowercase, words joined with -, no extra spaces. (This very site uses slugs in its lesson URLs.)
Why it matters: you decide what "correct" means before you see the code, so a confident-sounding answer cannot change your mind.
Add three cases to TESTS: " Python Tips " → "python-tips", "ONE" → "one", and "" → "". The prompt and the test run use them automatically.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.