English subtitles for clip: File:7 - 2 - Lecture 5.2 Loop Idioms (15 05).webm

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
1
00:00:01,020 --> 00:00:06,200
Loop idioms are how we construct loops.

2
00:00:06,200 --> 00:00:10,080
And we're going to, the loops kind of
have some kind of a goal in mind.

3
00:00:10,080 --> 00:00:11,970
Finding the largest, we played with that.

4
00:00:11,970 --> 00:00:15,360
Finding the smallest, counting the
number of things,

5
00:00:15,360 --> 00:00:18,230
looking for lines that start with pound
signs, something like that.

6
00:00:18,230 --> 00:00:21,630
They, they have a kind of a high-level
view of what they're supposed to do,

7
00:00:21,630 --> 00:00:25,830
and then we have to kind of build a
loop to accomplish that.

8
00:00:25,830 --> 00:00:29,600
And and this goes back to how we have to
think like a computer, right?

9
00:00:29,600 --> 00:00:32,000
We have to say, hey computer,

10
00:00:32,000 --> 00:00:34,080
do this over and over and over again,
and then I'll

11
00:00:34,080 --> 00:00:36,300
get what I want once you've done that
over and over again.

12
00:00:36,300 --> 00:00:37,760
You have to do something a million times.

13
00:00:37,760 --> 00:00:39,100
I'm not going to sit here and wait.

14
00:00:39,100 --> 00:00:41,030
At the end, I'll get what I want.

15
00:00:41,030 --> 00:00:42,770
So I call these kind of "smart loops",

16
00:00:42,770 --> 00:00:45,460
or how to kind of build
intelligence into loops.

17
00:00:48,170 --> 00:00:50,640
So, for example, we want the largest
number.

18
00:00:50,640 --> 00:00:51,400
Right?

19
00:00:51,400 --> 00:00:53,860
But we have to construct a loop that will

20
00:00:53,860 --> 00:00:57,020
get us the largest number thinking
like a computer.

21
00:00:57,020 --> 00:00:59,200
Okay? Thinking computationally.

22
00:00:59,200 --> 00:01:00,920
Thinking like a computer.

23
00:01:00,920 --> 00:01:03,550
So the idea is that we have some kind

24
00:01:03,550 --> 00:01:06,320
of a loop and we're going to
go through this list,

25
00:01:06,320 --> 00:01:10,170
some list of things, and this is
going to run a bunch of times.

26
00:01:10,170 --> 00:01:11,510
And, but the way we're going to do it is

27
00:01:11,510 --> 00:01:14,130
we're going to set something up
before the loop starts.

28
00:01:14,130 --> 00:01:17,720
We're going to do something to each of the
things that's being looked at,

29
00:01:17,720 --> 00:01:21,800
and at the end, we're going to get the
result we're looking for.

30
00:01:21,800 --> 00:01:22,560
Okay?

31
00:01:22,560 --> 00:01:25,310
And so in the middle it's kind of like
working.

32
00:01:25,310 --> 00:01:27,580
It's in the middle working,
da, da, da, da, da.

33
00:01:27,580 --> 00:01:29,270
And then here is the payoff.

34
00:01:29,270 --> 00:01:34,290
The payoff is at the end when we get the
information that we're interested in.

35
00:01:34,290 --> 00:01:37,880
So I will sort of use in the
next few examples

36
00:01:37,880 --> 00:01:39,880
this simple loop,

37
00:01:39,880 --> 00:01:41,870
and right now it doesn't do much.

38
00:01:41,870 --> 00:01:44,140
It does a print Before and it
has this variable

39
00:01:44,140 --> 00:01:48,180
thing that goes through the successive
values of these numbers.

40
00:01:48,180 --> 00:01:50,950
And it prints it out, right?
So that middle part says

41
00:01:50,950 --> 00:01:54,500
run this six times, once for
each of those values.

42
00:01:54,500 --> 00:01:55,330
And then After. Okay?

43
00:01:55,330 --> 00:01:58,710
And so we will add some intelligence
at the beginning, we'll add

44
00:01:58,710 --> 00:02:01,910
some intelligence in the middle, and we'll
add some intelligence at the end.

45
00:02:01,910 --> 00:02:04,790
And then the whole thing will
accomplish what we want.

46
00:02:04,790 --> 00:02:08,170
Right now this is kind of not that
intelligent.

47
00:02:08,170 --> 00:02:12,580
So now what I want to do, is I want to
review the thing we did, and I want you

48
00:02:12,580 --> 00:02:14,895
to remember what the largest number is,
and I'm going to

49
00:02:14,895 --> 00:02:17,760
show you a sequence of numbers in order.

50
00:02:17,760 --> 00:02:18,590
Ready?

51
00:02:18,590 --> 00:02:20,942
One, I'll do it kind of quickly, because
you've seen this before.

52
00:02:20,942 --> 00:02:23,630
So, I'm only showing you one number
at a time.

53
00:02:23,630 --> 00:02:26,110
So you want to tell me what the
largest number is.

54
00:02:26,110 --> 00:02:30,236
So here we go.
The first number is 9.

55
00:02:30,236 --> 00:02:34,125
The second number is 41.

56
00:02:34,125 --> 00:02:39,072
The third number is 12.
The fourth number is 3.

57
00:02:39,072 --> 00:02:45,697
The fifth number is 74.
And the sixth number is 15.

58
00:02:45,697 --> 00:02:47,790
So what was the largest number?

59
00:02:51,040 --> 00:02:54,735
Did you have to go back?
Or did you remember how to do it?

60
00:02:54,735 --> 00:02:59,978
Okay, well, I will give you a clue.
It was 74.

61
00:02:59,978 --> 00:03:02,440
Okay? That's because I know.

62
00:03:02,440 --> 00:03:06,450
Okay, now if you did that and you had to
do that for 20 or 30 numbers,

63
00:03:06,450 --> 00:03:08,680
you'd have to create a mental algorithm in

64
00:03:08,680 --> 00:03:13,148
your head to approach it and stay
concentrated, focused.

65
00:03:13,148 --> 00:03:15,530
So, you would've created a
variable in your head

66
00:03:15,530 --> 00:03:17,170
called largest_so_far.

67
00:03:18,610 --> 00:03:22,020
I would show you the first number, which
would be 9, and you would go hmm.

68
00:03:22,020 --> 00:03:25,120
Well, 9 is larger than 1, negative 1.

69
00:03:25,120 --> 00:03:28,430
So I will keep that. That's the new
largest I've seen so far.

70
00:03:28,430 --> 00:03:32,062
That's pretty awesome, because it's way
better than negative 1.

71
00:03:32,062 --> 00:03:36,860
41? I thought 9 was good.
But 41, that is a lot better.

72
00:03:36,860 --> 00:03:37,822
So I'm going to keep that one.

73
00:03:37,822 --> 00:03:40,831
That's the, that's the best.
It's the largest we've seen so far.

74
00:03:40,831 --> 00:03:41,779
We've only seen two numbers.

75
00:03:42,890 --> 00:03:45,460
But the best we've so far is 41.

76
00:03:45,460 --> 00:03:50,520
So 12 is not larger. Who, who
cares about that?

77
00:03:50,520 --> 00:03:54,060
It's not as big as 41 so we'll just go
right on to the next, on to the next.

78
00:03:54,060 --> 00:03:58,220
3, that's lame when we are
looking for large numbers.

79
00:03:58,220 --> 00:04:01,640
So we skip, oh, 74. 74, that's a
rockingly large number.

80
00:04:01,640 --> 00:04:02,870
So we're going to, that's a lot.

81
00:04:02,870 --> 00:04:05,180
That's actually the largest we've
seen so far

82
00:04:05,180 --> 00:04:08,214
because it's bigger than 41,
and 41 was the former champion

83
00:04:08,214 --> 00:04:13,410
largest we've seen so far.
And there's 74, so we keep that one.

84
00:04:13,410 --> 00:04:15,900
I don't know how many letters, of these
things you're going to see, right?

85
00:04:15,900 --> 00:04:19,930
We could see lots of them.
But the next one we see 15.

86
00:04:19,930 --> 00:04:21,550
Well, that's no good.

87
00:04:21,550 --> 00:04:25,010
We've got 74 already.
74's like totally awesome.

88
00:04:25,010 --> 00:04:25,620
Right?

89
00:04:25,620 --> 00:04:27,260
So now, oh, we're done.

90
00:04:27,260 --> 00:04:31,550
So, hey, we're done and so 74
is the champion.

91
00:04:32,660 --> 00:04:33,670
That is the largest.

92
00:04:33,670 --> 00:04:39,160
It's not even the largest so far
any more, it's actually the largest.

93
00:04:39,160 --> 00:04:40,560
It's the largest.

94
00:04:40,560 --> 00:04:43,710
So again, we had this thing
at the top, we had this loop in

95
00:04:43,710 --> 00:04:46,190
the middle, and at the bottom is
where you kind of get the payoff.

96
00:04:46,190 --> 00:04:47,480
And the payoff is

97
00:04:47,480 --> 00:04:49,090
not in the middle.

98
00:04:49,090 --> 00:04:51,220
while we're largest so far, largest so
far, largest so far,

99
00:04:51,220 --> 00:04:52,690
but at the end it turned out

100
00:04:52,690 --> 00:04:54,270
once you've looked at all the variables,

101
00:04:54,270 --> 00:04:58,330
all the values, the largest so far
is indeed the largest.

102
00:04:58,330 --> 00:04:58,940
Okay.

103
00:04:58,940 --> 00:05:01,180
So here's the algorithm for this.

104
00:05:01,180 --> 00:05:02,960
I have some variables, and remember

105
00:05:02,960 --> 00:05:06,820
that underscores are valid characters in
variables.

106
00:05:06,820 --> 00:05:10,650
Now [COUGH] I'm being a little
over-explicit in this.

107
00:05:10,650 --> 00:05:13,540
So I have a variable called
largest_so_far.

108
00:05:13,540 --> 00:05:19,003
Then what I do is I set it to 1,
negative 1.

109
00:05:19,003 --> 00:05:23,879
Then I print Before so we can see that
largest_so_far is negative 1.

110
00:05:23,879 --> 00:05:28,133
Then we have a for loop and my variable
iteration variable is the_num.

111
00:05:28,133 --> 00:05:32,953
So that's going to take on the successive
values: 9, 41, 12, 3, 74, 15,

112
00:05:32,953 --> 00:05:36,233
and run this indented loop of code, okay?

113
00:05:36,233 --> 00:05:41,122
And so the_num will be 9,
first time through.

114
00:05:41,122 --> 00:05:44,172
If the_num, 9, is greater than

115
00:05:44,172 --> 00:05:49,418
largest_so_far, then grab the_num
and assign

116
00:05:49,418 --> 00:05:55,364
it into largest_so_far.
Then print at the end of each loop,

117
00:05:55,364 --> 00:06:00,990
largest_so_far and the_num.
So, so, in effect, the_num is 9.

118
00:06:00,990 --> 00:06:04,840
We compare it to negative 1, and
negative 1, 9 is higher.

119
00:06:04,840 --> 00:06:07,265
So we make largest_so_far be 9.

120
00:06:09,370 --> 00:06:14,710
Next time through the loop, next time
through the loop, num is 41.

121
00:06:14,710 --> 00:06:20,180
So we compare largest_so_far with 41, and
we like it, so we store it.

122
00:06:20,180 --> 00:06:24,080
So we like it, we run it, and we print
our 41 is the largest we've seen so far.

123
00:06:25,330 --> 00:06:26,700
And we run again.

124
00:06:26,700 --> 00:06:31,816
We come in, the_num now points to 12.
the_num, 12, is

125
00:06:31,816 --> 00:06:37,152
not greater than 41, and so we skip.
So, the largest

126
00:06:37,152 --> 00:06:45,299
so far stays 41, and we see 12.
Similarly, the_num advances to 3.

127
00:06:45,299 --> 00:06:46,578
We skip.

128
00:06:46,578 --> 00:06:50,059
So we saw 3, but the largest
so far is still 41.

129
00:06:50,059 --> 00:06:55,900
Continuing, the_num is now 74.
It runs, 74 is

130
00:06:55,900 --> 00:07:02,306
greater than 41, and so we run
this code. And so we say 74

131
00:07:02,306 --> 00:07:06,520
is stuck in largest_so_far,
and indeed, then we print

132
00:07:06,520 --> 00:07:09,381
it out, and largest so far is now 74.

133
00:07:09,381 --> 00:07:11,139
We continue on.

134
00:07:11,139 --> 00:07:12,508
We go up one more time.

135
00:07:12,508 --> 00:07:17,535
The_num points to 15, but 15
is not larger than 74.

136
00:07:17,535 --> 00:07:18,760
And so we skip.

137
00:07:18,760 --> 00:07:22,840
We print out 15 and 74, and then
we come out and

138
00:07:22,840 --> 00:07:26,700
at the end, at the end, we get
the largest so far.

139
00:07:26,700 --> 00:07:28,400
It, the name no matter, no longer,

140
00:07:28,400 --> 00:07:30,330
I mean it's kind of the largest

141
00:07:30,330 --> 00:07:33,540
so far at the end is the largest,
but the variable name.

142
00:07:33,540 --> 00:07:35,320
Okay? Got it?

143
00:07:37,590 --> 00:07:41,230
That's one idiom.
So let's just switch to another idiom.

144
00:07:42,570 --> 00:07:44,510
Now counting, how many things are we

145
00:07:44,510 --> 00:07:46,170
going to, how many times is loop
going to execute?

146
00:07:46,170 --> 00:07:48,380
How things are we going to find
in the loop?

147
00:07:48,380 --> 00:07:50,020
It's all kind of the same notion.

148
00:07:50,020 --> 00:07:53,706
And the pattern is really simple.
We start some variable zork.

149
00:07:53,706 --> 00:07:55,133
A better name for this would be count.

150
00:07:55,133 --> 00:07:57,870
But I want to call it zork.

151
00:07:57,870 --> 00:08:02,435
And then we have a loop, and then in the
loop we just add 1 to zork,

152
00:08:02,435 --> 00:08:04,076
and at the end, zork.

153
00:08:04,076 --> 00:08:08,880
That should be light blue right there.
zork should be the total count.

154
00:08:08,880 --> 00:08:11,530
Now of course we can look at it and say
it's going to be 6, but

155
00:08:11,530 --> 00:08:13,780
assume this loop is looping through a
million

156
00:08:13,780 --> 00:08:15,338
lines in the file or something like that.

157
00:08:15,338 --> 00:08:20,598
So it's [SOUND], so it's cheating to
kind of look at it and say, ooh, it's 6,

158
00:08:20,598 --> 00:08:23,520
because we want to actually compute it.
So it's really simple.

159
00:08:23,520 --> 00:08:27,892
You know, zork starts at 0.
It's going to run zork is 1 now, and

160
00:08:27,892 --> 00:08:34,290
2, 3, 4, 5, 6, and then we've run out of
stuff and then we print out 6.

161
00:08:34,290 --> 00:08:35,000
Okay?

162
00:08:35,000 --> 00:08:36,261
So that's kind of the idiom, right?

163
00:08:36,261 --> 00:08:41,160
Before, during, and after, right?
We do something before, we do

164
00:08:41,160 --> 00:08:47,090
something during, and, and in a sense this
zork here is the number we've seen so far.

165
00:08:47,090 --> 00:08:49,260
And at the end it becomes kind of the
total number.

166
00:08:52,090 --> 00:08:54,360
Summing in a loop, very similar.

167
00:08:54,360 --> 00:08:58,410
Again, you have to think of this is, there
is a whole bunch of variables here.

168
00:08:58,410 --> 00:09:00,860
We start a variable at 0.

169
00:09:00,860 --> 00:09:04,333
Each time through the loop, we add
whatever it is that we're seeing.

170
00:09:04,333 --> 00:09:09,622
Instead of adding 1 we're
adding 9, 41, 12, 3, 74, 15.

171
00:09:09,622 --> 00:09:16,292
And zork would be best thought of as
running total.

172
00:09:16,292 --> 00:09:17,910
So, zork is the running total.

173
00:09:17,910 --> 00:09:20,610
And so if we look at the numbers 9,

174
00:09:20,610 --> 00:09:25,500
running total's 9, running total's 50,
running total's 62, 65, 139, 154.

175
00:09:25,500 --> 00:09:29,790
And then we skip out and at the end, the
running total becomes the total.

176
00:09:31,150 --> 00:09:32,330
Okay?

177
00:09:32,330 --> 00:09:35,350
So, that's another of these patterns
that, sort of,

178
00:09:35,350 --> 00:09:36,730
we do something at the beginning, we

179
00:09:36,730 --> 00:09:39,880
do something in the middle, and we have

180
00:09:39,880 --> 00:09:42,920
something very nice for ourselves
at the end.

181
00:09:46,800 --> 00:09:49,320
Finding the average of a sequence of
values

182
00:09:49,320 --> 00:09:52,740
is the combination of the
two previous patterns.

183
00:09:52,740 --> 00:09:56,190
This time I am going to use
more mnemonic variables.

184
00:09:56,190 --> 00:09:57,850
A variable called count.

185
00:09:57,850 --> 00:09:59,560
Everyone calls this count.

186
00:09:59,560 --> 00:10:02,977
Sum, now total would maybe be
a better word for this.

187
00:10:02,977 --> 00:10:07,177
The running total. And then, so the count
and the sum start out at 0, and

188
00:10:07,177 --> 00:10:12,327
then each time through the loop, count equals
count plus 1, so we're adding 1 to count.

189
00:10:12,327 --> 00:10:15,616
Sum equal sum plus value, so we're
adding 1 to to sum.

190
00:10:15,616 --> 00:10:17,120
I mean adding the value.

191
00:10:17,120 --> 00:10:21,310
Value of course being
9, 41, 12, 3, 74, 15.

192
00:10:21,310 --> 00:10:24,390
And then at the very end we can
print out the number.

193
00:10:24,390 --> 00:10:29,190
We have six things with a total of 154,
and then we calculate the average.

194
00:10:29,190 --> 00:10:33,800
Of course these are integer numbers, and
so this is a truncating division.

195
00:10:33,800 --> 00:10:37,715
So 154 over 6 equals 25 and

196
00:10:37,715 --> 00:10:40,831
not 25 point something.

197
00:10:40,831 --> 00:10:43,910
In Python 3000, Python 3, it'd be better.

198
00:10:43,910 --> 00:10:50,004
But so the average, the integer average is
of the numbers we just looked at, is 25.

199
00:10:50,004 --> 00:10:53,610
So sometimes we're searching, like
for a needle in a haystack.

200
00:10:53,610 --> 00:10:57,460
Looking for something and again
you have to think of like

201
00:10:57,460 --> 00:11:00,610
you're handed some amount of data and you
gotta hunt for something.

202
00:11:00,610 --> 00:11:02,980
And there might be a million things and
you might only want five of them.

203
00:11:02,980 --> 00:11:04,450
And you can either look by hand
or you can write

204
00:11:04,450 --> 00:11:07,430
a loop that's got an if statement that
says found it.

205
00:11:07,430 --> 00:11:10,300
Maybe I found it at line seven
or found it wherever.

206
00:11:10,300 --> 00:11:13,620
So this is filtering or finding or
searching, looking

207
00:11:13,620 --> 00:11:15,830
for a needle in a haystack, in a loop.

208
00:11:16,850 --> 00:11:20,210
And so the, the idea basically is
that we have this loop,

209
00:11:20,210 --> 00:11:24,865
it's going to go through all the
values, 9, 41, 12, 3, 74.

210
00:11:24,865 --> 00:11:28,290
But we put in the loop, we embed
an if statement.

211
00:11:28,290 --> 00:11:31,300
If the value we're looking at is greater
than 20, print I found it.

212
00:11:32,390 --> 00:11:39,764
So when value is 9, this is going to do
nothing and just go and make value be 41.

213
00:11:39,764 --> 00:11:44,500
And then value 41, oop, yep, there we go,
print Large number, so off this comes.

214
00:11:45,840 --> 00:11:49,746
Then value becomes 12, nothing happens,
value becomes 3, nothing happens,

215
00:11:49,746 --> 00:11:53,580
value becomes 74, oops, this
time it's going to happen.

216
00:11:53,580 --> 00:11:55,920
So out comes Large number 74.

217
00:11:55,920 --> 00:12:00,550
Then value becomes 15, nothing happens,
and then value is all done,

218
00:12:00,550 --> 00:12:02,610
and so it comes and finishes.

219
00:12:02,610 --> 00:12:08,257
So this is the searching or
filtering or catching or, or whatever.

220
00:12:08,257 --> 00:12:10,473
Okay?

221
00:12:11,473 --> 00:12:13,503
We can also sort of, if we don't just want

222
00:12:13,503 --> 00:12:16,446
to print everything out, we want to
say is something in there.

223
00:12:16,446 --> 00:12:18,152
Go look through this million things and

224
00:12:18,152 --> 00:12:20,831
tell me if blah exists.

225
00:12:20,831 --> 00:12:24,150
And in this we're going to introduce the
notion of Boolean variable.

226
00:12:24,150 --> 00:12:25,820
A Boolean is a true-false.

227
00:12:25,820 --> 00:12:29,200
It only has two values and we've
already used it in the while True.

228
00:12:29,200 --> 00:12:38,537
So that capital True, that is a constant,
just like 7 or 42 or 99, or "Sam".

229
00:12:38,537 --> 00:12:40,410
And so we're going to make this
variable called found.

230
00:12:40,410 --> 00:12:44,510
Now found is a mnemonic value, variable.
It's just a name I picked.

231
00:12:44,510 --> 00:12:46,220
So found equals False.

232
00:12:46,220 --> 00:12:48,380
This is going to be false,
until we find what

233
00:12:48,380 --> 00:12:50,880
we're looking for and then it's
going to switch to true.

234
00:12:50,880 --> 00:12:53,100
So it starts out and it's false.

235
00:12:53,100 --> 00:12:55,870
Then we're going to run this
bit of code three times.

236
00:12:57,760 --> 00:13:00,540
And if the value that we are looking at
is 3, then we're going

237
00:13:00,540 --> 00:13:05,430
to set found to be true, and we'll print
found value each time through.

238
00:13:05,430 --> 00:13:09,796
So value's going to take on 9, 41, 12, 3,
74, so we get a line

239
00:13:09,796 --> 00:13:12,904
of output for each one. And the
first time through

240
00:13:12,904 --> 00:13:15,804
it's not yet found, because we're
looking at a 9.

241
00:13:15,804 --> 00:13:17,271
Second time, it's not yet found.

242
00:13:17,271 --> 00:13:20,830
We looked at 41, still false. So it could
stay false for long time.

243
00:13:21,940 --> 00:13:23,180
Oh, we found a true.

244
00:13:23,180 --> 00:13:25,360
And then that means that this code is
going to run once.

245
00:13:25,360 --> 00:13:28,306
And so you can kind of think of this
found variable as sticky.

246
00:13:28,306 --> 00:13:31,342
It's going to stay false, and then
the rest of the loop

247
00:13:31,342 --> 00:13:34,590
it's going to stay true, and at
the end it is true.

248
00:13:34,590 --> 00:13:35,860
Now the way we usually do these
kinds of things

249
00:13:35,860 --> 00:13:36,750
is we don't bother with this
print statement,

250
00:13:36,750 --> 00:13:39,970
so we wouldn't see all this stuff.

251
00:13:39,970 --> 00:13:42,349
All we'd see is Before False, After True.

252
00:13:42,349 --> 00:13:44,800
And After would just tell us
that yeah, we found it.

253
00:13:44,800 --> 00:13:48,130
There was a 3 somewhere in
that long list of numbers.

254
00:13:48,130 --> 00:13:50,150
Okay? I am just adding this print
statement so we can

255
00:13:50,150 --> 00:13:55,530
kind of trace it. But basically this
loop, sort  of from here to here, is asking

256
00:13:55,530 --> 00:14:00,130
the question, is there the number 3 in the
list that we're about to go through?

257
00:14:01,260 --> 00:14:02,360
Okay?
Now...

258
00:14:03,870 --> 00:14:07,860
How could, I'll just give you a second and
ask you a quick question.

259
00:14:07,860 --> 00:14:09,000
You can pause if you want.

260
00:14:11,130 --> 00:14:14,360
How could you improve this loop
using the break?

261
00:14:14,360 --> 00:14:16,845
Where might you put a break
to make this loop smarter?

262
00:14:16,845 --> 00:14:23,230
[SOUND].

263
00:14:23,230 --> 00:14:26,380
It's okay if you didn't, if it
doesn't jump out at you.

264
00:14:26,380 --> 00:14:28,880
So, if you think about it.

265
00:14:28,880 --> 00:14:33,307
Once you hit true, there's really little
point in looking at the rest of them.

266
00:14:33,307 --> 00:14:37,307
There just is no point.
So we could put a break right here.

267
00:14:38,580 --> 00:14:43,190
Inside this block.
You'd say, look, I'm looking for a 3.

268
00:14:43,190 --> 00:14:45,240
All I care is whether I found it or not.

269
00:14:45,240 --> 00:14:50,440
If I find it, I mark it to true that I
found it, and I get out of the loop.

270
00:14:50,440 --> 00:14:51,530
Why bother?

271
00:14:51,530 --> 00:14:52,820
Why do all these things?

272
00:14:52,820 --> 00:14:55,100
Right, just get out.
Okay?

273
00:14:55,100 --> 00:14:56,990
So don't worry about it.

274
00:14:56,990 --> 00:15:00,490
I'm just pointing that out, that's one of
the places where break could be used.

275
00:15:00,490 --> 00:15:03,660
The loop functions either way it just, it
just looks through all the rest

276
00:15:03,660 --> 00:15:04,250
of them as well.

277
00:15:06,610 --> 00:15:08,540
Okay. So.