Coding homework help that explains the bug.

Paste the code and what it does wrong. Get the line where it goes off, the reason, and a way to test the fix yourself.

5 free questions a day. No account, no card.

A program that almost works is harder to fix than one that crashes. The output is close, the error message is no help, and reading the same lines again shows you what you meant instead of what you typed. Nerdly traces the code one line at a time with real values, which is the fastest way to see where the two part ways.

A worked example

This Python function should return the sum of a list. For [3, 4, 5] it returns 9 instead of 12.

def total(nums):
    result = 0
    for i in range(1, len(nums)):
        result += nums[i]
    return result
  1. The list has 3 items, at positions 0, 1 and 2.
  2. range(1, 3) produces 1 and 2. Position 0 is never visited.
  3. Trace it: result starts at 0, adds nums[1] = 4 to make 4, then adds nums[2] = 5 to make 9.
  4. The missing 3 is nums[0]. The loop starts one place too late: an off-by-one error.
  5. Fix: start the range at 0 with range(len(nums)), or loop over the values directly.
def total(nums):
    result = 0
    for n in nums:
        result += n
    return result

Test it: total([3, 4, 5]) is now 12, and total([]) is 0, because the loop body never runs on an empty list.

How to ask

  • Say what you expected and what you got. “Should print 12, prints 9” finds the bug faster than “it does not work”.
  • Paste the full error. The line number and the last line of the message carry most of the answer.
  • Ask for a trace. Seeing each variable change line by line is what the written exam asks you to do.

Learn the idea, not only the fix

After the bug is found, ask for a similar broken example and fix that one yourself. Then pick Quiz me on the topic before the test.

Run the code, not only read it

To see a program work, open the AI coding agent: it writes the files, runs them in your browser and fixes what fails, step by step, with an Explain as it goes switch for learning. For your own script, run Python online in the same workspace, NumPy and pandas included. Both need a free account. To build something of your own, start from a template (a game, a dashboard, a Chrome extension) or see which AI models code best and what each costs.

Keep going

Try one of these.

Each one opens the chat with the question in the box. Change it to yours.

Questions.

Something else? Email hello@nerdly.us

The ones intro courses use: Python, Java, JavaScript, C, C++, C# and SQL, plus HTML and CSS. CS1, CS2 and data structures topics are covered.

No. It reads the code and traces it by hand, the way you would on a test. Run the fix yourself to confirm it.

A free question holds about 12,000 characters, which is a few hundred lines. Paste the function that fails and the error message, not the whole project.

It explains, finds bugs and reviews code you wrote. Handing in code you did not write is against most course rules and against the honor code here.

No. One message is one question however many lines of Python or Java it holds, up to about 12,000 characters. That is 5 a day with no account and 10 with a free account; Plus is $9.99 a month for 150.

Program not doing what you meant?

5 questions a day, free. No account, no card, nothing to install.

Ask a question
Join on TelegramHelp