1
00:00:00,330 --> 00:00:02,940
This is a debugging exercise.

2
00:00:02,940 --> 00:00:06,270
So this is code that you wrote ages ago where

3
00:00:06,270 --> 00:00:08,670
you created a program that tests whether

4
00:00:08,670 --> 00:00:12,990
if an input is an odd or an even number.

5
00:00:12,990 --> 00:00:15,241
Now, however I've put some bugs in there.

6
00:00:15,241 --> 00:00:17,420
So I've been sneaky, and I have messed

7
00:00:17,420 --> 00:00:21,450
up the code a little bit and this happens a lot to us

8
00:00:21,450 --> 00:00:24,510
programmers, sometimes we do it unintentionally.

9
00:00:24,510 --> 00:00:27,008
Sometimes somebody else messes with our code or sometimes

10
00:00:27,008 --> 00:00:29,910
we've just written something that's completely nonsensical

11
00:00:29,910 --> 00:00:32,490
and it doesn't do what we want it to do.

12
00:00:32,490 --> 00:00:35,160
This is a really important skill.

13
00:00:35,160 --> 00:00:39,000
This along with being good at Googling is probably one

14
00:00:39,000 --> 00:00:43,410
of the most important skills for a professional developer.

15
00:00:43,410 --> 00:00:44,640
Don't feel bad just

16
00:00:44,640 --> 00:00:47,910
because you know the code is wrong and you have to fix it.

17
00:00:47,910 --> 00:00:50,077
This is something that I expect all developers

18
00:00:50,077 --> 00:00:51,960
to get good at.

19
00:00:51,960 --> 00:00:53,190
Take a look at the code.

20
00:00:53,190 --> 00:00:54,810
You know what it has to do.

21
00:00:54,810 --> 00:00:56,850
It has to take any given input

22
00:00:56,850 --> 00:01:00,750
and tell you if it's even number or an odd number.

23
00:01:00,750 --> 00:01:03,060
Identify and fix mistakes in it

24
00:01:03,060 --> 00:01:06,273
and then feel free to hit Submit to see

25
00:01:06,273 --> 00:01:08,130
if your code passes all the checks.

26
00:01:08,130 --> 00:01:11,280
I strongly encourage you to not look

27
00:01:11,280 --> 00:01:14,790
at your previous solution for odd or even

28
00:01:14,790 --> 00:01:17,283
and to figure it out from first principles.

29
00:01:18,180 --> 00:01:19,013
Have a go now.

30
00:01:21,480 --> 00:01:23,460
The solution is pretty quick and simple

31
00:01:23,460 --> 00:01:25,920
but finding it is not quick and simple.

32
00:01:25,920 --> 00:01:27,630
Hopefully, you managed to figure out

33
00:01:27,630 --> 00:01:31,710
that the bug here is where we've got

34
00:01:31,710 --> 00:01:35,940
if number % 2 == 0,

35
00:01:35,940 --> 00:01:39,030
a single equal (=) in Python is an assignment,

36
00:01:39,030 --> 00:01:41,610
it's saying let's put the right side

37
00:01:41,610 --> 00:01:45,930
of the equal sign into the container that's on the left,

38
00:01:45,930 --> 00:01:49,650
whereas, two equal signs (==) is checking for equality.

39
00:01:49,650 --> 00:01:52,034
So is the left hand side equal

40
00:01:52,034 --> 00:01:53,940
in value to the right hand side?

41
00:01:53,940 --> 00:01:56,460
And that's what we need to do when we want to check

42
00:01:56,460 --> 00:01:59,493
if a number is odd or even.

