Skip to content
Exit presentation

Programming Proper I

What the message says, and what it does not

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.

Jump to lesson

This track

  1. 0 Start here
  2. 1 The same program, typed instead of dragged
  3. 2 A box you can change, and a box you cannot
  4. 3 Four kinds of value, and why the quotes matter
  5. 4 What the signs do, and the one that does two jobs
  6. 5 A fork in the line
  7. 6 A loop that runs until something stops it
  8. 7 Once for each thing you have
  9. 8 What the message says, and what it does not
  10. 9 The big picture
  11. 10 Track quiz

Other tracks