In this video we'll be discussing some of the basics to debugging. In my videos, I get a lot of questions for help where people have errors and are not sure what the problem is. If they used some extremely simple debugging, they'd realize how obvious the answer is. Most of the time, the problem is a typo, followed closely by a misunderstanding of indentation and standards.
Standards how are how you organize your code. With python, unlike most languages, you define blocks of code, like functions, by indentation. Most python editors will automatically indent for you where it is necessary. With this, if you are ever coding along and find python automatically indenting you where you don't think it should, this should raise a flag for you to figure out.
There are some more in-depth common-issues that you'll find from time to time, you can find more debugging videos by searching for debugging in my channel. For now I will just keep these ones basic. The first error we'll discuss is the NameError: is not defined.
As obvious as this might appear to you, this gets people amazingly frequently. Just learn to recognize the "is not defined" as a high chance that you have typoed the definition of the variable or when you are calling it. Basically, you typo-ed somewhere.
variable = 55 print(varaible)Fail.
Next up, we have indentation issues. You will see "expected an indented block" as a popup when you never enter an indented block for something that requires it, like a function.
def task1(): def task2(): print('more tasks')
Nope.
So there was a lacking expected indent. How about an unexpected one?
def task(): print ('stuff') print('more stuff') print('stuff')
Denied.
Now what happens when you don't close off your strings and move to another line?
def task(): print('some people find themselves committing this too print('ouch...')
Nay. EOL while scanning string literal.
So there we have just a handful of very common errors. There are others from time to time, but they tend to be typos or indent issues quite often.