Errors
Errors#
By now, you’ve likely seen a few examples of errors. Let’s look at one in detail. Below, we’ve tried to access a variable that doesn’t exist. Python stops, but gives us a lot of helpful information. It tells us the name of the error, and gives a traceback. The traceback points to the line with the error. The final line gives more detail about this specific error - here it names the variable which we tried to access but wasn’t actually defined.
2*z
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [1], in <module>
----> 1 2*z
NameError: name 'z' is not defined
Try going back and looking at other errors from previous exercises/examples. Do they make sense? Here we’ve seen a NameError. See how many other different error types you can discover below.