1
00:00:01,230 --> 00:00:02,820
Now the next step

2
00:00:02,880 --> 00:00:07,230
and the next tip is pretty obvious. When the editor's giving you an error or when

3
00:00:07,230 --> 00:00:11,670
the console is giving you an error, fix the errors before you continue.

4
00:00:12,180 --> 00:00:16,379
Now, this is a little bit easier when you're dealing with errors in the editor,

5
00:00:16,440 --> 00:00:19,530
because it will actually highlight to you the line that's broken.

6
00:00:20,070 --> 00:00:23,520
So here we've got a print statement and when we hover over it,

7
00:00:23,790 --> 00:00:28,790
it tells us that it expected an indented block. So that should be a good enough

8
00:00:29,280 --> 00:00:32,189
clue to tell us what's actually wrong.

9
00:00:32,610 --> 00:00:36,660
So if we go ahead and indent this block, then that error goes away.

10
00:00:37,170 --> 00:00:40,830
But that's not the only error, no. When you run this code,

11
00:00:40,890 --> 00:00:45,750
you still get another error. So let's say that I am a 12-year-old girl,

12
00:00:46,980 --> 00:00:48,090
we get another error.

13
00:00:48,570 --> 00:00:52,470
And this error does not show up when we write the code,

14
00:00:52,770 --> 00:00:57,770
but it only shows up depending on what input we gave to this age variable.

15
00:00:59,160 --> 00:01:03,900
So now we have a different type of error. We have an error that's in the console.

16
00:01:04,470 --> 00:01:06,210
How do we solve this error? Well,

17
00:01:06,210 --> 00:01:10,680
the easiest way is just to select the parts of the error

18
00:01:10,710 --> 00:01:15,710
that's not specific to your code like this age greater than 18 or line 84,

19
00:01:17,100 --> 00:01:21,480
but the part that is pretty much common to whenever anybody gets this error.

20
00:01:22,200 --> 00:01:25,920
And now if we copy it and we paste it into Google,

21
00:01:26,910 --> 00:01:30,390
then you can see there's a lot of other people who've had this issue.

22
00:01:30,960 --> 00:01:32,850
And if we read what the problem is,

23
00:01:32,910 --> 00:01:36,840
it tells us that you're getting the input from the console as a string

24
00:01:37,020 --> 00:01:40,020
and you must cast that input as an int

25
00:01:40,380 --> 00:01:45,380
before you try to do these numerical operations like comparisons. Back over here,

26
00:01:46,380 --> 00:01:50,310
that's exactly what we're trying to do on line 84 right here.

27
00:01:50,940 --> 00:01:55,940
This age comes out of this input function and it returns a string.

28
00:01:58,350 --> 00:02:01,020
And so in order to turn this into a number,

29
00:02:01,230 --> 00:02:06,230
we of course have to cast it or type convert it into an integer.

30
00:02:07,230 --> 00:02:10,560
And now when we run our code and we give it our age,

31
00:02:10,830 --> 00:02:12,810
it no longer errors out.

32
00:02:13,380 --> 00:02:16,620
And if I tell it that I am in fact 21,

33
00:02:16,860 --> 00:02:18,540
which is still not my real age,

34
00:02:19,050 --> 00:02:21,900
then we actually get the print statement working.

35
00:02:23,130 --> 00:02:28,130
But remember that the errors don't always solve all of your bugs, like this.

36
00:02:31,170 --> 00:02:34,650
In this case there are no errors with my code whatsoever,

37
00:02:34,920 --> 00:02:37,860
it's just not doing what I want it to do.

38
00:02:38,430 --> 00:02:42,960
And these are the most frustrating bugs to debug because nobody is helping you

39
00:02:42,960 --> 00:02:45,450
here. There is no errors that you can Google,

40
00:02:45,660 --> 00:02:47,790
there's no underlines that you can check.

41
00:02:48,210 --> 00:02:52,650
You actually have to rely on your skills as a programmer to fix this.

42
00:02:53,310 --> 00:02:58,310
Now we, of course, know that this needs to be an fstring in order to insert that

43
00:03:00,130 --> 00:03:03,430
variable into this position in the curly braces.

44
00:03:04,120 --> 00:03:08,110
But if you didn't, then this would be a lot harder to debug.

45
00:03:09,430 --> 00:03:13,840
Experience comes in really handy with debugging and the more bugs that you

46
00:03:13,840 --> 00:03:18,100
solve, the better you get at it. So go onto the internet,

47
00:03:18,130 --> 00:03:22,660
try to help people in Stack Overflow. Go on to the discord channel for the course,

48
00:03:22,720 --> 00:03:27,220
try to solve other people's bugs and you will find yourself getting stronger

49
00:03:27,550 --> 00:03:29,020
and better day by day.

