Getting Started

For those Learning a programming language, understanding the syntax is really the heart of understanding how the code is to be written and implemented. A crucial next step once you start to understand syntax and code structures is to understand the possible errors that you will run into when your code doesn’t run. A thorough understanding of what the error is and why you’re receiving it makes diagnosing and troubleshooting the error much faster. When I tried to self-teach myself Python initially when I encountered an error I would copy and paste it into the black hole that is stackoverflow.com and get lost reading about other people’s issues. It wasn’t until I took a formally-taught university programming course and learned about the various error types and their significance in relation to the issue of my code that I became less reliant on "googling for answers".
Avoiding Crisis
Having a more systematic approach to how to handle errors when you encounter them makes the troubleshooting part of Error Handling that much easier. With experience and a better understanding of the Python syntax, you will learn to quickly identify what type of error you are getting and the root cause and how to fix them. The last thing you want to do is enter crisis mode, where you quickly become timeboxed and are stuck with errors. Taking a quick breath and approaching it with a checklist to help break down the issue is what we are going to try and help you assemble in this article.

Troubleshooting Process
- Identify the error type.
- Read the description for details on why that error/exception was fired off. It’s pretty good practice to refer to the Python documentation and/or the documentation of the libraries that may also be affected by the error. Most documentation will detail the requirements of the inputs for a function or call the outputs and it’s the type and any other requirements that may be necessary.
- Determine if the error is of the following types: a) syntax/typo error or b) process/logic related.
- If the error is syntax-related, see where the error is occurring in your code (usually the traceback will highlight the line and location of the error) to fix.
- If the error is process/logic related, review the error type and description and then look to see where the error is occurring and the processes that you are the code to execute. Many times it’s better to refer back to what processes you are trying to accomplish in that particular part of your code to see if you satisfy the requirements of that function or line of code.
- Return and fix the errors once diagnosed.
Traceback Dissection
Below I have copied a simple traceback for a syntax error and will break down how to interpret/understand it:

- Error Type – The specific error that caused the file to not correctly run
- Error Description – A brief description of text that proved a description of the error or exception that occurred.
- Error Location – Depending on the type of error (usually for Syntax errors) it will denote where the program determines that something should or should not be there (i.e. missing symbols, parenthesis, brackets, etc…)
- Error Line Location – Like above, sometimes the line in the code with an issue is highlighted
- Error Traceback – Now to compile and run code, commands are sent and other files are running in the background that you may not be aware of and at times this can be really helpful if you have higher-order functions, and/or calling functions from other files, the traceback can give insights to where and what’s being fired off when you hit run.
Common Error Types:

Wrap Up
To better be able to solve those pesky Error issues, breakdown the Error Traceback, understand what the Error you are receiving, and decide if it’s a quick fix/typo type of issue or a process/logic one that may need you to reask what you are trying to accomplish. In a perfect world, the less reliant you can make yourself on sites like stackoverflow.com and other question-type forums the better off you will be. Some of the hardest parts of learning programming are like learning a new language, you want to be able to fluent in all situations and not have to run back to Google Translate all the time. Having a systematic approach to Errors will make you a master troubleshooter!
If you have any questions about this article, please let me know. Also if there are things you’d like to be explored or explained respond back!