Read bottom-up, then open the line
Beginners see a red wall and delete half the program. Slow down. Most errors give you three gifts: where it happened (file and line), what failed (the exception or compiler message), and often a hint about the kind of mistake (undefined name, missing semicolon, wrong type). Read the last lines first in Python tracebacks. In C and C++, read the first error — later errors are often noise from the first one.
Open the exact line. Look at the names on that line. Ask: did I spell this variable the same way I created it? Did I close the quote? Did I call a function that does not exist yet? Fix one issue, run again, read the next message. That rhythm is debugging. Rewriting from scratch because the message felt scary is not.
Copy the exact error into your notes once. Teaching yourself the vocabulary of failures is half the skill.
Common message classes
| You see… | Often means… | First check |
|---|---|---|
| NameError / undeclared | Typo or used before create | Spelling and scope |
| SyntaxError / expected ‘;’ | Structure broken | Quotes, brackets, semicolons |
| TypeError / cannot convert | Wrong kind of value | int vs string, nulls |
| Index out of range | List/array too short | Lengths and off-by-one |
| Segmentation fault (C/C++) | Bad pointer or overflow | Init, bounds, & vs * |
Practice on purpose: break a working example, read the message, fix it. The Try Python editor and language Try pages make that cheap. Then read How to Debug Without Guessing for the method around the message.