1 00:00:07,940 --> 00:00:11,660 It's really valuable when you get an error, 2 00:00:11,660 --> 00:00:13,810 to look at the error message, 3 00:00:13,810 --> 00:00:15,060 it can tell you a lot. 4 00:00:15,060 --> 00:00:18,810 First, the first thing you notice is that there's that pink box and you got 5 00:00:18,810 --> 00:00:21,240 an error and then you may be tempted to just 6 00:00:21,240 --> 00:00:23,790 go look at your code and try to figure out what's wrong. 7 00:00:23,790 --> 00:00:28,190 But, it's really worth investing the time to look at the error message, 8 00:00:28,190 --> 00:00:31,100 it'll tell you a line number which will be a good clue. 9 00:00:31,100 --> 00:00:35,900 And if you start to learn to decode the specific messages, 10 00:00:35,900 --> 00:00:37,295 they will also be really helpful. 11 00:00:37,295 --> 00:00:39,935 So let's go through an example here, 12 00:00:39,935 --> 00:00:44,660 here's a program that's going to ask for a couple of inputs. 13 00:00:44,660 --> 00:00:52,320 It's going to ask what time we want to start. 14 00:00:52,320 --> 00:00:57,725 How long we want to wait and at the end it's supposed to print. 15 00:00:57,725 --> 00:01:03,155 If I enter three o'clock or three is our start time, 16 00:01:03,155 --> 00:01:04,640 then I want to wait four hours, 17 00:01:04,640 --> 00:01:08,280 it should tell us that that's seven o'clock. 18 00:01:09,230 --> 00:01:12,360 Let's see what actually happens. 19 00:01:12,360 --> 00:01:15,975 What's the current time and hours, let's say three. 20 00:01:15,975 --> 00:01:18,345 How many hours do you want to wait, 21 00:01:18,345 --> 00:01:21,835 four and it should print out seven, 22 00:01:21,835 --> 00:01:26,160 but instead we get that pink error box. 23 00:01:26,450 --> 00:01:29,370 Let's go see what it's telling us, 24 00:01:29,370 --> 00:01:35,850 it says first of all that line five is a good place to look, 25 00:01:36,010 --> 00:01:40,505 it says the type of problem that we have is a name error 26 00:01:40,505 --> 00:01:45,649 and in particular wait time int is not defined. 27 00:01:45,649 --> 00:01:48,990 So let's go look at line five. 28 00:01:49,870 --> 00:01:54,680 This means that it actually executed one through four. 29 00:01:54,680 --> 00:01:58,760 Everything was going fine until it got to line five. 30 00:01:58,760 --> 00:02:03,170 Whenever you see an assignment statement like we have on line five, 31 00:02:03,170 --> 00:02:07,890 what happens is we first evaluate the right hand side, 32 00:02:07,890 --> 00:02:10,530 the stuff after the equal sign, and then, 33 00:02:10,530 --> 00:02:15,280 we'll assign it to the variable weight_time_int. 34 00:02:17,810 --> 00:02:20,410 So it's going to get a value, 35 00:02:20,410 --> 00:02:25,040 but it only gets that value after we evaluate the right side. 36 00:02:25,040 --> 00:02:33,565 So the right side says to look up the current value of wait time int but, 37 00:02:33,565 --> 00:02:35,690 it is not defined. 38 00:02:35,690 --> 00:02:38,255 So by the time we get to line five, 39 00:02:38,255 --> 00:02:42,310 wait_time_int has not previously been set. 40 00:02:42,310 --> 00:02:45,280 When you try to look it up on line five, 41 00:02:45,280 --> 00:02:46,640 we get this error. 42 00:02:46,640 --> 00:02:48,695 So that should give us a clue. 43 00:02:48,695 --> 00:02:51,890 Now we have to go back to what we were trying to do and figure 44 00:02:51,890 --> 00:02:55,100 out what's going on and say, "Oh wait a minute. 45 00:02:55,100 --> 00:02:58,510 We were trying to take this input that we got, 46 00:02:58,510 --> 00:03:00,040 that was gonna be a string, 47 00:03:00,040 --> 00:03:02,345 that was maybe four hours, 48 00:03:02,345 --> 00:03:04,865 but this isn't the name of the variable. 49 00:03:04,865 --> 00:03:09,450 Wait time SDR is the variable." 50 00:03:09,860 --> 00:03:12,130 So if I do that, 51 00:03:12,130 --> 00:03:14,360 I have a better chance of it working. 52 00:03:14,360 --> 00:03:17,120 Let's see if that does. 53 00:03:17,120 --> 00:03:19,740 I start at three, 54 00:03:19,740 --> 00:03:23,650 and say that I want to wait four hours. 55 00:03:24,080 --> 00:03:32,370 And now I get the seven that I was expecting to get. See you next time.