Coding · Debug

Find Out Why Your Code Gives the Wrong Result

When code runs but the answer is wrong, trace the mistake step by step and learn how to spot it.

Prompt Text output

My code runs without errors, but the result is wrong. Here is the code: [CODE]. With this input: [TEST_INPUT], I expected [EXPECTED_OUTPUT], but I got [ACTUAL_OUTPUT]. Please walk through the code line by line using my example input, showing what each value becomes at each step, like following a recipe. Point to the exact line where things start going wrong and explain why in simple words. Then give me the fix. After that, suggest two or three other small test inputs I can try myself to be confident it now works, including an unusual case such as an empty list or a zero.

Fill in the brackets

[CODE]
Paste the code that gives the wrong answer
[TEST_INPUT]
e.g. prices 10, 20 and 30 with a 10% discount
[EXPECTED_OUTPUT]
e.g. 54
[ACTUAL_OUTPUT]
e.g. 60

How to use

  1. Copy the prompt.
  2. Replace the text inside [BRACKETS] with your own details.
  3. Paste it into ChatGPT or another AI assistant.
  4. Read the result and ask for changes if needed.

Tip: Use a small, simple example input so the step-by-step walk-through is easy to follow.