Get unstuck on a coding error with hints instead of the answer
A plain-English explanation of your error and step-by-step hints, so you learn to debug instead of copying a fix.
The prompt
Help me fix a coding error, but teach me instead of handing me the fix.
What I'm building and which step I'm on: [PASTE THE MILESTONE FROM STEP 2, or describe it]
Language: [e.g. "Python 3", "JavaScript"]
My code: [PASTE THE RELEVANT PART - remove any passwords, API keys, or personal data first]
Full error message: [PASTE THE WHOLE THING, not just the last line]
What I expected to happen: [DESCRIPTION]
What I've already tried: [DETAILS]
How to help:
1. Explain in plain words what the error message means and how to read it (e.g. which line it points to and why the real cause may be earlier).
2. Give hints in escalating order: Hint 1 (where to look), Hint 2 (what's wrong there), Hint 3 (how to fix it in principle). Stop after each hint and let me try.
3. Show the corrected code only if I ask for it after the hints.
4. Fix only the problem I asked about. Don't rewrite my whole program or change my style.
5. If there's no error but the output is wrong, help me add print statements or use a debugger to compare what the code does with what I expected.
After it's solved, give me:
- A one-line rule I can remember to avoid this error.
- A general debugging habit this problem teaches.
This is step 3 of the "Learn to code by building your first project" pack. It works on its own for any beginner coding error.
Highlighted [brackets] are blanks to replace with your own details.
Fill in the blanks and use this promptMore Software Development prompts
What to fill in
- PASTE THE MILESTONE FROM STEP 2, or describe it
- e.g. "Python 3", "JavaScript"
- PASTE THE WHOLE THING, not just the last line
- DESCRIPTION
- DETAILS
How this prompt is built
This prompt follows the Few-Shot structure (Few-shot prompting). A few-shot prompt includes one or more worked examples of the input and the output you want, so the model can copy the pattern instead of guessing it.
Related prompts
- Find which change caused a regressionCreates a systematic plan to pinpoint the commit, deploy, or config change that broke something that used to work.
- Break my first coding project into small buildable stepsA milestone plan where every step leaves you with a working program and tells you what to learn next.
- Find and fix a race condition or concurrency bugAnalyzes code for race conditions, deadlocks, and lost updates, explains the exact interleaving that fails, and proposes a safe fix.
- Explain what a piece of code doesPlain-language walkthrough of unfamiliar code: purpose, flow, key parts, and gotchas.