Skip to content
Your progress

Checking your sign-in…

Who's learning?

Each profile keeps its own read lessons, badges, streak, and practice scores on this device.

Lesson 8 of 11

What the message says, and what it does not

Show on a big screen

8 min

Text size

Four lines in the ticket program are broken. Not one of them runs.

Loading lab…

The run stops on line 3.
Step 1 of 4
  1. The run stops on line 3.
  2. This chip names the line it stopped on.
  3. This line says what went wrong.
  4. This line suggests a way to fix it.

The rule

An error is the machine telling you what it could not do. It is not a score.

An error message names the line the run stopped on. It says what could not be done there. The cause can be on that line or above it. Fix one thing, then run it again.

These four sentences are this editor's own. Other tools phrase them differently, or run some of these lines anyway.

Four broken lines, and the sentence each one produced
The lineWhat came back
print(total);I do not know what total is. Did you make it with let first?
print(min(fare, riders, 2));min needs 2 values, but you gave 3.
print("Fare " - fare);You cannot do a text - a number. Check the values on this line.
print(riders / 0);You cannot divide by zero. Check the number on the right.

The first message names line 3, where total is used. The missing line is above it, where the box should be made. The machine can only say where it stopped.

In the other three, the cause is on the line itself. min picks the smaller of its values. Here min needs exactly 2 values.

Change four lines at once and you cannot tell which change mattered.

Try the lab to finish this lesson.