BeginnerCoder

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:

  1. Write the test cases yourself — normal input, messy input, empty input.
  2. Put them into the prompt.
  3. Run the assistant's answer against the same tests.
  4. 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.

Want it another way?
Task

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.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.