1 00:00:00,030 --> 00:00:04,800 To begin, go ahead and select the Debug Odd or Even exercise. 2 00:00:05,490 --> 00:00:07,140 All right. So now that you 3 00:00:07,140 --> 00:00:11,550 have learned all about the tips and tricks and the steps to go through 4 00:00:11,550 --> 00:00:12,900 to debug your code, 5 00:00:13,260 --> 00:00:18,120 it's time to put some of that into action. In the upcoming three lessons, 6 00:00:18,270 --> 00:00:22,170 I've got a bunch of code that you've already written before. 7 00:00:22,590 --> 00:00:24,150 The first one, for example, 8 00:00:24,180 --> 00:00:28,470 is the Odd or Even code challenge that you did a long time ago. 9 00:00:29,070 --> 00:00:33,690 Now, the important thing is for you to not just go back to the old code, 10 00:00:33,690 --> 00:00:38,460 copy it, paste it in, submit, done. That isn't going to teach you anything. 11 00:00:38,670 --> 00:00:42,600 There's no point doing this if you're not going to learn. But instead, 12 00:00:42,630 --> 00:00:47,580 what I want you to do is to look at the code, see what it meant to do. 13 00:00:47,610 --> 00:00:49,410 So for example, in this case, 14 00:00:49,740 --> 00:00:54,740 we're trying to input a number and then we're trying to get our code to check 15 00:00:54,870 --> 00:00:59,220 to see if it's an odd number or an even number, and then print it out. Now, 16 00:00:59,250 --> 00:01:03,420 in most of these upcoming code exercises, they're going to be broken, 17 00:01:03,570 --> 00:01:07,020 but it's your job to try and fix it 18 00:01:07,080 --> 00:01:10,950 to make sure that it does what it's supposed to. In this case, 19 00:01:10,980 --> 00:01:13,560 you should be able to type in a number and it should print, 20 00:01:13,590 --> 00:01:17,820 "This is an even number." if it's even, "This is an odd number." if it's odd. 21 00:01:18,240 --> 00:01:21,990 Once you've spotted the problem and debugged and fixed your code, 22 00:01:22,290 --> 00:01:25,860 then I'll go through the solution with you. So pause the video now. 23 00:01:28,520 --> 00:01:29,353 All right. So, 24 00:01:29,630 --> 00:01:33,710 as always, let's first hit run to see if it actually works or not. 25 00:01:34,280 --> 00:01:39,110 And in this case, it doesn't even run. It gives us a syntax error straightaway, 26 00:01:39,500 --> 00:01:44,450 and it tells us that on line three, we've got some invalid syntax. Now, 27 00:01:44,510 --> 00:01:47,450 on line three, that's actually not all that specific. 28 00:01:47,840 --> 00:01:50,210 But notice how sometimes when you get errors, 29 00:01:50,240 --> 00:01:55,240 it's actually nice enough to have a little arrow pointing towards the bit of the 30 00:01:55,490 --> 00:01:58,520 code in that line that it thinks is problematic. 31 00:01:59,150 --> 00:02:01,880 So let's try and fix this error before we proceed. 32 00:02:02,510 --> 00:02:06,140 So why does it have an issue with this equal sign? Well, 33 00:02:06,170 --> 00:02:11,170 remember that two equal signs is checking and one equal sign is assignment. 34 00:02:13,490 --> 00:02:14,323 So in this case, 35 00:02:14,330 --> 00:02:18,530 we're actually saying number % 2 should be equal to zero, 36 00:02:18,560 --> 00:02:22,310 which is nonsense. It doesn't actually make any sense. Instead, 37 00:02:22,340 --> 00:02:26,720 what we wanted was two equal signs so that we can check that the left-hand side 38 00:02:26,960 --> 00:02:28,910 is equal to the right-hand side. 39 00:02:29,480 --> 00:02:33,890 And now if we hit run and we enter a number, it should now work. 40 00:02:34,010 --> 00:02:35,210 Did you manage to get it right? 41 00:02:35,720 --> 00:02:40,580 If not, be sure to review some of the lessons on debugging and try to apply it in 42 00:02:40,610 --> 00:02:44,810 the next exercise. So once you're ready, head over to the next lesson.