It's really valuable when you get an error,
to look at the error message,
it can tell you a lot.
First, the first thing you notice is that there's that pink box and you got
an error and then you may be tempted to just
go look at your code and try to figure out what's wrong.
But, it's really worth investing the time to look at the error message,
it'll tell you a line number which will be a good clue.
And if you start to learn to decode the specific messages,
they will also be really helpful.
So let's go through an example here,
here's a program that's going to ask for a couple of inputs.
It's going to ask what time we want to start.
How long we want to wait and at the end it's supposed to print.
If I enter three o'clock or three is our start time,
then I want to wait four hours,
it should tell us that that's seven o'clock.
Let's see what actually happens.
What's the current time and hours, let's say three.
How many hours do you want to wait,
four and it should print out seven,
but instead we get that pink error box.
Let's go see what it's telling us,
it says first of all that line five is a good place to look,
it says the type of problem that we have is a name error
and in particular wait time int is not defined.
So let's go look at line five.
This means that it actually executed one through four.
Everything was going fine until it got to line five.
Whenever you see an assignment statement like we have on line five,
what happens is we first evaluate the right hand side,
the stuff after the equal sign, and then,
we'll assign it to the variable weight_time_int.
So it's going to get a value,
but it only gets that value after we evaluate the right side.
So the right side says to look up the current value of wait time int but,
it is not defined.
So by the time we get to line five,
wait_time_int has not previously been set.
When you try to look it up on line five,
we get this error.
So that should give us a clue.
Now we have to go back to what we were trying to do and figure
out what's going on and say, "Oh wait a minute.
We were trying to take this input that we got,
that was gonna be a string,
that was maybe four hours,
but this isn't the name of the variable.
Wait time SDR is the variable."
So if I do that,
I have a better chance of it working.
Let's see if that does.
I start at three,
and say that I want to wait four hours.
And now I get the seven that I was expecting to get. See you next time.