WEBVTT

00:00.630 --> 00:05.880
Every programmer makes mistakes and most make mistakes every day.

00:06.300 --> 00:13.920
Although good programmers might create errors and they also know how to respond to these errors efficiently.

00:14.100 --> 00:20.640
Now let's look at an error you will likely to make early on and learn how to fix it.

00:20.670 --> 00:28.800
So we will write some code that generates an error on purpose and enter the this code here.

00:29.340 --> 00:30.090
Message.

00:31.630 --> 00:35.080
Message here and we will write.

00:35.410 --> 00:35.950
Hello.

00:38.180 --> 00:38.990
By then.

00:39.470 --> 00:40.190
Parash.

00:41.380 --> 00:42.190
Or Python.

00:45.940 --> 00:49.180
After that, we will print message.

00:52.390 --> 00:58.870
So if an error occurs in your program, the Python interpreter does its best to help you figure out

00:58.870 --> 01:00.550
where the problem is.

01:02.840 --> 01:09.140
So the interpreter provides a traceback when a program cannot run successfully.

01:09.410 --> 01:09.980
Here.

01:10.220 --> 01:11.060
That's it.

01:12.040 --> 01:14.140
It's actually widen it a little bit.

01:17.500 --> 01:25.570
The traceback is a record of where the interpreter ran into trouble when trying to execute your code.

01:26.390 --> 01:33.320
Here's an example of the traceback that Python provides after you have accidentally misspelled a variable's

01:33.320 --> 01:33.890
name.

01:34.850 --> 01:35.510
Here.

01:35.690 --> 01:37.820
Let's actually use this marker.

01:37.820 --> 01:38.390
Yes.

01:39.040 --> 01:41.470
So here, this is our first line, right?

01:41.740 --> 01:44.770
This is our first line that Python gave us.

01:45.190 --> 01:48.460
So here we have error.

01:49.830 --> 01:55.830
And we also have print function names and name message is not defined.

01:56.670 --> 01:58.110
So here.

01:59.380 --> 02:04.900
The output reports that an error occurs in line two.

02:05.890 --> 02:06.370
Here.

02:06.490 --> 02:12.010
Error occurs in line two of the main dot pi.

02:13.780 --> 02:17.620
Python file and the interpreter shows this line.

02:20.800 --> 02:26.470
To help us to stop the error quickly and tells us what kind of error it found.

02:26.860 --> 02:34.810
In this case, it found the name error and reports that the variable being printed message has not been

02:34.810 --> 02:39.970
defined and Python cannot identify the variable name provided.

02:40.330 --> 02:46.960
A name error usually means we either forgot to set a variable's value before using it or we made a spelling

02:46.960 --> 02:50.050
mistake when entering the variables name.

02:50.440 --> 02:59.380
If Python finds a variable name that's similar to one it doesn't recognize, it will ask if that's the

02:59.380 --> 03:01.210
name you meant to use.

03:01.360 --> 03:08.440
In this example we omitted the letter s in the variable name message in the second line and the python

03:08.440 --> 03:14.500
interpreter doesn't spell check your code, but it does ensure that the variable names are spelled consistently.

03:15.400 --> 03:21.490
So, for example, watch what happens when we spell the message incorrectly in the line that defines

03:21.490 --> 03:22.530
the variable.

03:22.540 --> 03:23.830
Let's actually make this.

03:25.150 --> 03:25.960
That's it.

03:25.960 --> 03:30.850
In this case, the program runs successfully the variable name match.

03:30.850 --> 03:38.380
So Python sees no easy programming language are very strict, but they disregard good and bad spelling.

03:38.380 --> 03:44.020
As a result, you don't need to consider English spelling and grammar rules when you are trying to create

03:44.020 --> 03:45.820
a variable names and writing code.

03:45.880 --> 03:52.840
So many programming errors are simple single character typos in one line of program.

03:52.840 --> 03:59.860
If you find yourself spending a lot of time searching for one of these errors, know that you are in

03:59.860 --> 04:00.700
a good company.

04:01.380 --> 04:09.600
So many experienced and talented programmers spent hours hunting down these kinds of tiny errors.

04:09.630 --> 04:17.130
Try to laugh about it and move on, knowing it will happen frequently throughout your programming live.
