Common Errors Python Tutorial




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.


There exists 1 challenge(s) for this tutorial. for access to these, video downloads, and no ads.


There exists 5 quiz/question(s) for this tutorial. for access to these, video downloads, and no ads.

The next tutorial:






  • Python Introduction
  • Print Function and Strings
  • Math with Python
  • Variables Python Tutorial
  • While Loop Python Tutorial
  • For Loop Python Tutorial
  • If Statement Python Tutorial
  • If Else Python Tutorial
  • If Elif Else Python Tutorial
  • Functions Python Tutorial
  • Function Parameters Python Tutorial
  • Function Parameter Defaults Python Tutorial
  • Global and Local Variables Python Tutorial
  • Installing Modules Python Tutorial
  • How to download and install Python Packages and Modules with Pip
  • Common Errors Python Tutorial
  • Writing to a File Python Tutorial
  • Appending Files Python Tutorial
  • Reading from Files Python Tutorial
  • Classes Python Tutorial
  • Frequently asked Questions Python Tutorial
  • Getting User Input Python Tutorial
  • Statistics Module Python Tutorial
  • Module import Syntax Python Tutorial
  • Making your own Modules Python Tutorial
  • Python Lists vs Tuples
  • List Manipulation Python Tutorial
  • Multi-dimensional lists Python Tutorial
  • Reading CSV files in Python
  • Try and Except Error handling Python Tutorial
  • Multi-Line printing Python Tutorial
  • Python dictionaries
  • Built in functions Python Tutorial
  • OS Module Python Tutorial
  • SYS module Python Tutorial
  • Python urllib tutorial for Accessing the Internet
  • Regular Expressions with re Python Tutorial
  • How to Parse a Website with regex and urllib Python Tutorial
  • Tkinter intro
  • Tkinter buttons
  • Tkinter event handling
  • Tkinter menu bar
  • Tkinter images, text, and conclusion
  • Threading module
  • CX_Freeze Python Tutorial
  • The Subprocess Module Python Tutorial
  • Matplotlib Crash Course Python Tutorial
  • Python ftplib Tutorial
  • Sockets with Python Intro
  • Simple Port Scanner with Sockets
  • Threaded Port Scanner
  • Binding and Listening with Sockets
  • Client Server System with Sockets
  • Python 2to3 for Converting Python 2 scripts to Python 3
  • Python Pickle Module for saving Objects by serialization
  • Eval Module with Python Tutorial
  • Exec with Python Tutorial