1 00:00:07,910 --> 00:00:10,740 Let's go through some common errors. 2 00:00:10,740 --> 00:00:14,790 These are typical mistakes that programmers make, 3 00:00:14,790 --> 00:00:17,640 so it would be helpful just to have seen some of 4 00:00:17,640 --> 00:00:22,110 the error messages and how to recognize the problems and how to fix them. 5 00:00:22,110 --> 00:00:26,980 So, one that we've already seen is forgetting a parenthesis. 6 00:00:29,420 --> 00:00:32,385 Here, it tells us there's a syntax error, 7 00:00:32,385 --> 00:00:34,650 it doesn't really know exactly what's wrong but 8 00:00:34,650 --> 00:00:37,875 it tells us there's a syntax error on line six. 9 00:00:37,875 --> 00:00:40,635 Whenever you see a syntax error, 10 00:00:40,635 --> 00:00:43,640 you should always look on the line number that it says. 11 00:00:43,640 --> 00:00:45,895 If everything looks right there, 12 00:00:45,895 --> 00:00:49,115 you should really look on the lines above it. 13 00:00:49,115 --> 00:00:55,800 In this case, we forgot to close the parenthesis on line five. 14 00:00:55,800 --> 00:00:57,720 So, even though it says line six, 15 00:00:57,720 --> 00:01:01,620 it's line six where the Python Interpreter realized there was a problem, 16 00:01:01,620 --> 00:01:06,890 that is on line five where you really have the problem and where you should correct it. 17 00:01:07,260 --> 00:01:16,710 We should add that parenthesis, and now it works. 18 00:01:18,650 --> 00:01:23,940 Our next set of errors involve variable names. 19 00:01:23,940 --> 00:01:28,720 The first thing to realize is that capitalization really matters. 20 00:01:28,880 --> 00:01:35,385 In this case, we go to line three and on line three, 21 00:01:35,385 --> 00:01:41,595 it tries to do capital turtle dot small turtle. 22 00:01:41,595 --> 00:01:44,035 First thing to know is that, 23 00:01:44,035 --> 00:01:45,920 capital turtle and small turtle are 24 00:01:45,920 --> 00:01:52,240 two completely different variable names and small turtle is the name of this module. 25 00:01:52,240 --> 00:01:56,355 In that module, you can find the turtle class. 26 00:01:56,355 --> 00:02:04,240 So, we really need it to have small turtle dot capital turtle. 27 00:02:10,400 --> 00:02:14,980 So, another example of a variable naming problem occurs 28 00:02:14,980 --> 00:02:21,355 here and sometimes you got to watch out and we have a big window to draw in, 29 00:02:21,355 --> 00:02:25,620 that there may be an error message down below. 30 00:02:25,830 --> 00:02:34,750 In this case, the name right is not defined on line six. 31 00:02:35,360 --> 00:02:38,920 You might look at this and say, 32 00:02:39,890 --> 00:02:41,970 this is all just fine, 33 00:02:41,970 --> 00:02:44,845 we're telling june to go right by 90 degrees. 34 00:02:44,845 --> 00:02:48,040 That's not the correct way to say it. 35 00:02:48,040 --> 00:02:57,980 We first have to mention the object and then the dot and then the method. 36 00:02:57,980 --> 00:03:01,815 So, june should go right by 90, 37 00:03:01,815 --> 00:03:04,570 not right dot june. 38 00:03:05,330 --> 00:03:08,380 So, let's fix that. 39 00:03:22,520 --> 00:03:26,860 Now, we get it without the error message. 40 00:03:30,590 --> 00:03:34,300 Here's another variable naming problem. 41 00:03:34,730 --> 00:03:40,925 We create a turtle named June and then we tell June to move right by 90, 42 00:03:40,925 --> 00:03:44,550 again the error messages down 43 00:03:44,550 --> 00:03:49,150 off the screen and it's saying June is not defined on line six. 44 00:03:49,150 --> 00:03:51,960 So, we're telling June to go right, 45 00:03:51,960 --> 00:03:54,405 there's no binding for the variable June. 46 00:03:54,405 --> 00:03:57,330 There is a binding for the variable small j 47 00:03:57,330 --> 00:04:01,355 june but this is a situation where our small j june, 48 00:04:01,355 --> 00:04:06,655 capital J June, not the same variable and so we got that error. 49 00:04:06,655 --> 00:04:10,830 Fix that, no more error there. 50 00:04:13,590 --> 00:04:17,950 Another common type of error is when we invoke 51 00:04:17,950 --> 00:04:22,330 a function but don't pass in the right values, 52 00:04:22,330 --> 00:04:25,210 the right arguments that it's expecting. 53 00:04:25,210 --> 00:04:30,475 So here, we've got a program 54 00:04:30,475 --> 00:04:37,640 where June is supposed to move forward and turn right and do that repeatedly. 55 00:04:37,650 --> 00:04:42,610 But we didn't tell it how many times to do it, 56 00:04:42,610 --> 00:04:45,100 so we invoked the range function but we didn't pass in 57 00:04:45,100 --> 00:04:48,350 an argument saying how many times to do it. 58 00:04:50,840 --> 00:04:56,500 We get an error and it tells us that on line five, 59 00:04:59,360 --> 00:05:02,655 we tried to invoke the range function. 60 00:05:02,655 --> 00:05:07,170 It wanted to have at least one argument but we didn't give it any. 61 00:05:07,170 --> 00:05:12,260 There are no values in the parentheses and it wants at least one. 62 00:05:12,260 --> 00:05:14,520 So, we should have said something like, 63 00:05:14,520 --> 00:05:17,020 do this three times. 64 00:05:19,430 --> 00:05:22,960 Let's give it an argument of three, 65 00:05:24,380 --> 00:05:28,275 and now it works just fine. 66 00:05:28,275 --> 00:05:31,330 So, those are some kinds of common errors that you're 67 00:05:31,330 --> 00:05:34,645 likely to see as you start writing your own programs. 68 00:05:34,645 --> 00:05:37,250 We'll see you next time.