Debugging
It is time for us to dedicate a little more time to debugging our algorithms. In Chapter 5, Errors, we looked at some of the errors we can get when writing code. In Chapter 8, Identifying Challenges with Solutions, we also saw some of the debugging tools that are built into Python to find errors in our code. Now, we are going to go deeper into algorithm debugging, looking at some problem situations and proposed algorithms, determining what causes the errors we are alerted to in the console, as well as those errors that we know exist because the outcome is not what is expected but we do not get an error message from Python. Some of these bugs may not be flagged by Python in any way, which is why we will now focus on some specific errors and how to avoid them. Debugging is a critical skill in programming, and it is impossible to cover all scenarios, but we will show some of the things you can look for when writing your solutions.
In this chapter, we will cover the following...