Debugging pt. 1
[vocab] debug | error message
→ Lab Assignment: “Debugging Madlib” on repl.it
Errors are valuable
“Imperfect is more interesting than perfect…”
…because we get to learn from mistakes.
Debugging is the process of identifying and removing errors from a piece of code. It helps to use the scientific method, to test ideas one at a time.
Error messages are printed by the shell whenever a program encounters an error while running. It’s important to read these because they give us clues about what we might need to fix. Error messages usually include a line number and the type of error found (ie. SyntaxError).
# Another common type of error:NameError: name '...' is not defined# This happens when you use an unknown variable or function name, something that has never been defined
Looking at a bunch of code can feel just like this at times. In the beginning, it takes a lot of time and patience just to figure out what’s happening in the code. But it gets easier with practice. The more you debug, the better you will get.