Skip to main content

4.8) Debugging


Here are a few tips for debugging programs:

  • As you write your program, look out for the colour highlighting in the editor. It can highlight issues like typos or missing quotation marks
  • Execute the program and read the error messages starting from the last line and moving up. The most useful information is usually at the end. Errors include the line number and IDLE highlights the problem. Try and understand what type of error you’re dealing with, it will guide you towards potential causes
  • If you have an issue with a specific line, comment it out with # so you can debug the rest of the code
  • Print results of intermediate operations or values and types of variables to understand where you went wrong
  • Test your code, don’t just assume it does the right thing. For example, check the result of operations for specific values