1
00:00:00,540 --> 00:00:01,110
Welcome back.

2
00:00:01,710 --> 00:00:07,770
Now, up until now, we saw the break, key word that we can use to break out of a loop.

3
00:00:07,950 --> 00:00:13,080
And you see here that we're able to loop with a for loop, but with a while loop, as soon as we break,

4
00:00:13,080 --> 00:00:13,620
we're done.

5
00:00:14,160 --> 00:00:17,310
We've just well broken out of the loop.

6
00:00:17,730 --> 00:00:20,580
But could we do that in a for loop?

7
00:00:21,320 --> 00:00:21,890
Let's find out.

8
00:00:24,250 --> 00:00:28,590
Yep, brake keyboard works in a for loop as well.

9
00:00:29,750 --> 00:00:35,720
But there's actually two other things that we can use besides break.

10
00:00:36,620 --> 00:00:47,330
One is called continue, and you can see here again, Blue highlighting if I do continue here and I

11
00:00:47,330 --> 00:00:48,230
click run.

12
00:00:49,980 --> 00:00:56,250
There you go, we get our looping again, but you're thinking, why, why do we need this?

13
00:00:56,580 --> 00:00:59,040
Like, it seems completely useless, right?

14
00:00:59,730 --> 00:01:01,320
Well, a break.

15
00:01:01,320 --> 00:01:06,620
When we use the breaks, they meant it breaks out of the current and closing loop.

16
00:01:06,840 --> 00:01:12,480
So when we used a break statement, we broke out of this loop right.

17
00:01:12,480 --> 00:01:14,880
This whole while loop, we just exited it.

18
00:01:15,330 --> 00:01:16,530
And same with the for loop.

19
00:01:16,530 --> 00:01:20,430
We completely exited, however, with a continue.

20
00:01:20,790 --> 00:01:27,570
What we're saying is, hey, whatever happens when you hit this line, continue onto the top of the

21
00:01:27,570 --> 00:01:28,680
inclosing loop.

22
00:01:28,950 --> 00:01:30,420
So the current a closing loop.

23
00:01:30,420 --> 00:01:30,930
What is it?

24
00:01:31,080 --> 00:01:32,070
It's this for loop.

25
00:01:32,310 --> 00:01:38,220
So it's going to go back to the for loop so that if I do something like print here.

26
00:01:39,880 --> 00:01:43,900
So that we get it printed twice or you know what, let's just move print.

27
00:01:45,660 --> 00:01:46,470
Down here.

28
00:01:50,260 --> 00:01:57,460
And then same here, we're going to just print out the bottom after continue if I click, run.

29
00:01:59,160 --> 00:02:04,740
Nothing gets printed because as soon as it sees continue, it's going to say, OK, I'm going to go

30
00:02:04,740 --> 00:02:10,170
back to the loop and it's going to keep going, keep going, keep going until, well, the loop ends

31
00:02:10,320 --> 00:02:14,160
so that we never actually hit line ten in line for.

32
00:02:15,340 --> 00:02:18,970
So that becomes really useful and conditional logic as well.

33
00:02:19,750 --> 00:02:27,280
Finally, the third one is called Pass and Pass is but not very useful.

34
00:02:28,000 --> 00:02:31,900
It essentially does nothing if I click run here.

35
00:02:33,680 --> 00:02:36,410
And again, it shows me here, line 10, something's wrong.

36
00:02:36,620 --> 00:02:45,110
Well, we have to move print up to the top so that while we don't get my list of index of three, which

37
00:02:45,110 --> 00:02:45,860
doesn't exist.

38
00:02:47,330 --> 00:02:49,520
So, again, going back here, if I click run.

39
00:02:50,660 --> 00:02:59,150
Pass doesn't do absolutely anything, it just essentially passes to the next line, so why is that ever

40
00:02:59,150 --> 00:02:59,660
useful?

41
00:03:00,110 --> 00:03:07,550
It's very rare that you'll see pass in your code, but pass is a good way to have, let's say, a placeholder

42
00:03:07,550 --> 00:03:13,790
while you're coding, for example, you want to loop through the for loop, but we don't know what we

43
00:03:13,790 --> 00:03:14,530
want to do yet.

44
00:03:14,540 --> 00:03:18,110
And the code lets say that here we're still thinking about it.

45
00:03:18,650 --> 00:03:21,050
If I do this and I click run.

46
00:03:22,700 --> 00:03:25,750
I get an error here because whoa, whoa, whoa.

47
00:03:27,330 --> 00:03:34,650
Expected and indented block because now the for loop or the Python interpreters looking for the next,

48
00:03:34,650 --> 00:03:36,180
like, what am I supposed to do with the loop?

49
00:03:36,180 --> 00:03:38,060
I'm trying to loop and there's no code for me.

50
00:03:38,490 --> 00:03:46,020
So you can add a pass here to at least feel something for the for loop to say, hey, I'm thinking about

51
00:03:46,020 --> 00:03:50,610
it, I'm just going to pass it for now just so you have something so you don't bug me and I'll come

52
00:03:50,610 --> 00:03:51,000
back to it.

53
00:03:51,180 --> 00:03:52,170
So if I click run.

54
00:03:53,600 --> 00:03:59,270
That still works, so pass is one of those placeholders that we can use so that there is a line of code

55
00:03:59,270 --> 00:04:02,060
that does absolutely nothing that we can still pass through.

56
00:04:02,270 --> 00:04:08,420
Again, a very rare thing to see in production code while you're developing some developers like using

57
00:04:08,690 --> 00:04:11,090
Pass and they have a break.

58
00:04:11,090 --> 00:04:12,350
Continue and pass.

59
00:04:12,940 --> 00:04:13,790
I'll see you in the next one.
