Understanding errors
We had previously discussed errors generally; here, we will also include some additional discussions as we progress through the additional content within this book. But at this time, it will be helpful to go over a few more error examples, in particular, errors pertaining to the following:
- Syntax errors: these are created by misspelling, missing punctuation, and so on.
- Errors in logic: these are created when the code runs “correctly” but the results do not match our expectations.
- Type Errors: these are created when we try to use a value with one type, like a string, but the expected value was an int or float and vice versa
Let’s take a look at Syntax Errors first, but then we’ll dedicate a larger section to errors in logic. And we’ll conclude with a discussion on debugging.
Syntax errors
These can be fairly easy to identify, and Python provides us with some console messages to help us. Let’...