1
00:00:00,760 --> 00:00:01,150
OK.

2
00:00:01,180 --> 00:00:02,310
Welcome back, everybody.

3
00:00:02,360 --> 00:00:13,990
So in this lecture, we are going to be discussing a new topic which is nested loops, so nested loops

4
00:00:13,990 --> 00:00:22,930
are pretty much just the idea of having a loop or more inside of a another loop as many layers as you

5
00:00:22,930 --> 00:00:23,530
could think of.

6
00:00:23,540 --> 00:00:31,180
So having a loop inside of a loop or a loop inside of a loop, inside of a loop, inside of a loop,

7
00:00:31,180 --> 00:00:32,920
you know, continuing.

8
00:00:33,430 --> 00:00:36,490
This is the idea of nested loops in this lecture.

9
00:00:36,490 --> 00:00:43,030
We're just solely going to be covering a singly nested loop, which is just a loop inside of a loop.

10
00:00:43,300 --> 00:00:44,920
No more layers than that.

11
00:00:45,700 --> 00:00:50,890
And this can initially be quite a confusing topic, but an important thing to remember is that you can

12
00:00:50,890 --> 00:00:58,810
always go back to the execution flow of this and draw it out step by step so you can go through a loop

13
00:00:58,810 --> 00:01:04,960
and its inner loop and keep track of the variables that are changing for four loops and stuff like that.

14
00:01:05,500 --> 00:01:08,340
And it'll help you kind of figure out what is going on.

15
00:01:08,350 --> 00:01:15,340
So if it gets confusing, pull out a pen and paper kind of draw out a table, keep track of the values,

16
00:01:16,820 --> 00:01:24,460
make some drawings step by step to the code, and that'll be a good way to remind yourself of what's

17
00:01:24,460 --> 00:01:25,140
going on.

18
00:01:25,150 --> 00:01:31,660
If, after this lecture, you forget and become a little confused at what's really going on inside these

19
00:01:31,660 --> 00:01:32,890
nested loops loops.

20
00:01:33,580 --> 00:01:40,210
So one thing we do have to become comfortable with is the idea of for each time something happens.

21
00:01:41,020 --> 00:01:42,940
Another thing will happen multiple times.

22
00:01:42,940 --> 00:01:49,780
So when I say for each time, something happens that something is the outer loop and the another thing

23
00:01:49,780 --> 00:01:52,870
that happens multiple times is the inner loop.

24
00:01:54,160 --> 00:01:59,320
So I think the best way to explain this is to use an analogy.

25
00:01:59,860 --> 00:02:06,580
And in this analogy, what I am using is a sandwich shop, so you can imagine something like Subway.

26
00:02:06,580 --> 00:02:09,760
If you've ever been there, that's an international chain.

27
00:02:09,770 --> 00:02:11,620
So maybe it's a good idea to use that.

28
00:02:11,620 --> 00:02:16,030
And at this particular specific sandwich shop, we only have one employee working right now.

29
00:02:16,030 --> 00:02:26,560
So we have a line of clients here, and each client basically needs to be able to go through the sandwich

30
00:02:26,560 --> 00:02:33,910
bar and choose each one of the toppings and then pay before the next client is allowed to start that

31
00:02:33,910 --> 00:02:34,450
process.

32
00:02:35,490 --> 00:02:41,910
So this is the type of live control structure I'm talking about the turquoise or teal, kind of.

33
00:02:44,500 --> 00:02:49,270
Circle here is representing the outer loop, so everything that's in between.

34
00:02:50,290 --> 00:02:59,800
So I should say everything that is actually inside of this turquoise shape, but outside of the purple

35
00:02:59,800 --> 00:03:00,250
shape.

36
00:03:00,760 --> 00:03:03,520
So in this region, I'm actually going to trace it.

37
00:03:03,520 --> 00:03:12,520
So this looks this here and this area in this dollar sign over here and all of this that is considered

38
00:03:12,670 --> 00:03:16,450
the scope of the outer loop.

39
00:03:16,900 --> 00:03:18,750
Specifically, just the outer loop.

40
00:03:18,760 --> 00:03:26,290
Although the inner loop is still inside of the scope of the outer loop, the inner loop is represented

41
00:03:26,290 --> 00:03:27,250
by the purple.

42
00:03:27,250 --> 00:03:31,420
So everything inside the purple, which is the same which path that is the inner loop.

43
00:03:32,350 --> 00:03:41,440
So what we're going to do is have one client go into the inner loop and choose each one of these topping

44
00:03:41,440 --> 00:03:48,100
categories, which is a b for bread and for meat, and B for veggies.

45
00:03:48,100 --> 00:03:54,280
So they will iterate over each one of these and then they'll go back out into the outer loop and they

46
00:03:54,280 --> 00:03:59,320
will have to pay and then they'll be done and we can then start processing the next client.

47
00:04:00,550 --> 00:04:07,720
So let's go ahead and walk through this first client gets processed here in the outer loop and we then

48
00:04:07,720 --> 00:04:10,120
head into the inner loop with that client.

49
00:04:11,170 --> 00:04:16,490
This client chooses a bread, so that's one iteration of the inner loop.

50
00:04:16,510 --> 00:04:22,300
Then they go through and they choose the meat that is, say, next iterations of the second iteration

51
00:04:22,300 --> 00:04:22,990
of the Loop.

52
00:04:22,990 --> 00:04:30,010
And then they choose a type of veggies or multiple veggies, and that is the third iteration of the

53
00:04:30,010 --> 00:04:30,490
inner loop.

54
00:04:30,640 --> 00:04:36,610
They then exit the inner loop and go back into the outer loop to do one last thing, which is pay.

55
00:04:37,240 --> 00:04:39,910
And then they are done and we move.

56
00:04:40,180 --> 00:04:43,960
We process the second client and then bring them into the inner loop.

57
00:04:44,560 --> 00:04:48,910
They choose their bread, they choose their meat, they choose their veggies.

58
00:04:48,910 --> 00:04:53,500
They go out of that in a loop and they then pay the register.

59
00:04:54,100 --> 00:04:56,020
We then process the third client.

60
00:04:56,200 --> 00:05:02,230
This client chooses bread and then meat and then veggies, and then they go to the register and then

61
00:05:02,230 --> 00:05:03,640
we do the last client.

62
00:05:03,700 --> 00:05:08,920
They come into the inner loop and they iterate over bread, meat and then veggies and then pay.

63
00:05:08,920 --> 00:05:09,810
And then we are done.

64
00:05:11,840 --> 00:05:20,000
So I am now going to go over this with a code example that is pretty much the same as what we drew right

65
00:05:20,000 --> 00:05:20,300
here.

66
00:05:21,560 --> 00:05:27,590
So we're going to chase this code example of the sandwich bar here in code just to give you an overview.

67
00:05:28,190 --> 00:05:35,210
I start out by defining, declaring, initializing a variable here called line length.

68
00:05:35,240 --> 00:05:36,530
I say equal to four.

69
00:05:37,490 --> 00:05:45,020
I then have an array of type char that size three that's called toppings, and it has those symbols

70
00:05:45,020 --> 00:05:51,020
right B, M and V for bread, meat and vegetables, respectively.

71
00:05:52,860 --> 00:05:56,610
So then we start our loops, and this is where it gets interesting, so.

72
00:05:58,230 --> 00:06:04,380
We're starting out with a person here, and we're saying that our person starts out at person zero.

73
00:06:05,090 --> 00:06:11,420
We want to go as long as the person number is less than the line length.

74
00:06:11,460 --> 00:06:14,240
So that will be zero one to three.

75
00:06:14,250 --> 00:06:20,460
That is four times one for each of the four clientele of the four clients.

76
00:06:21,150 --> 00:06:26,100
We do a person plus plus because we're going to increment from one client to the other, right?

77
00:06:27,120 --> 00:06:34,680
So I'm going to move to this next line and I'm going to kind of now from this point on, keep track

78
00:06:35,130 --> 00:06:37,500
of these really important variables.

79
00:06:37,500 --> 00:06:39,300
So we are on person.

80
00:06:39,420 --> 00:06:42,450
Zero person equals zero to start with.

81
00:06:42,930 --> 00:06:49,740
We have now hit the line of our inner loop here, where we have top in position is equal to zero.

82
00:06:49,750 --> 00:06:57,450
You notice that we're also doing a tapping position less than three top position plus plus because there

83
00:06:57,450 --> 00:07:05,310
are three toppings and we care about going from zero one two, but not to three because that's sufficient.

84
00:07:05,640 --> 00:07:09,060
Zero one two two cycle across our top end positions.

85
00:07:10,780 --> 00:07:15,430
So now that we've had this line and we have started out with Typekit position on zero, we can go to

86
00:07:15,430 --> 00:07:18,220
this inner line inside the inner loop.

87
00:07:19,120 --> 00:07:24,070
We say we print out person, what is person zero?

88
00:07:24,070 --> 00:07:28,360
So Person Zero chose topping, then we see this array.

89
00:07:29,320 --> 00:07:35,320
We ask ourselves what is top position that is zero, so what is at top position index zero?

90
00:07:35,350 --> 00:07:36,310
It is B.

91
00:07:36,970 --> 00:07:41,860
Therefore, this whole sentence will be person zero chose topping B.

92
00:07:42,760 --> 00:07:50,110
Right, and then a space we now have finished with this iteration of the inner loop, so we go back

93
00:07:50,110 --> 00:07:56,350
up to the top and now we do a top in position plus plus, which brings us from top position was zero

94
00:07:56,350 --> 00:07:58,180
to top in position is now one.

95
00:07:59,340 --> 00:08:07,380
We go back into the loop and we say person zero, because person has not changed, we're still on person.

96
00:08:07,980 --> 00:08:12,300
The first person which is represented as persons zero, right, and that's what we started out on.

97
00:08:13,560 --> 00:08:21,130
This is still the first client in terms of just ordering, but the computer science position, you know,

98
00:08:21,150 --> 00:08:22,670
is zero because we're starting zero.

99
00:08:24,330 --> 00:08:30,270
So we say Person Zero chose topping, but now we're on one with position one inside here it's M.

100
00:08:30,270 --> 00:08:33,570
So we're saying person zero choice topping M and then a space.

101
00:08:34,080 --> 00:08:35,970
We go back up here now it's two.

102
00:08:35,970 --> 00:08:39,330
So we can say Person zero now chose topping V.

103
00:08:39,330 --> 00:08:41,580
It's the final topping right.

104
00:08:43,170 --> 00:08:46,320
We go back up here, we increment in position to three.

105
00:08:46,920 --> 00:08:51,300
But what we said is that we're not going to run the code inside this loop.

106
00:08:52,600 --> 00:08:58,180
If top position is not less than three, because this was our loop running condition, it has to be

107
00:08:58,180 --> 00:09:01,660
less than three since that condition is not satisfied.

108
00:09:01,990 --> 00:09:03,670
We are now finished with our loop.

109
00:09:03,680 --> 00:09:06,810
We will hit this bracket here and continue on to the code.

110
00:09:07,570 --> 00:09:12,970
Here we are now going to print out a new line character.

111
00:09:12,970 --> 00:09:16,070
So if you haven't seen this yet, it's similar to end line.

112
00:09:16,090 --> 00:09:21,490
It just prints out a new line so we can move on to a next to the next line of the console.

113
00:09:22,180 --> 00:09:24,790
And then we say Person zero.

114
00:09:25,690 --> 00:09:28,510
Paid and then we print out and in line, right?

115
00:09:28,900 --> 00:09:29,710
So they paid.

116
00:09:30,970 --> 00:09:35,380
Now we have finished with the outer loop because we hit this close bracket here, right?

117
00:09:35,380 --> 00:09:43,810
So we're done with everything inside the outer loop, so we go back to the top for the next iteration

118
00:09:44,380 --> 00:09:45,000
of the outer.

119
00:09:46,340 --> 00:09:52,070
Now that we're back up here, we can increment the person so person goes from zero to one.

120
00:09:53,410 --> 00:09:59,050
This condition says that will go as long as a person is less than line length, line length is four,

121
00:09:59,080 --> 00:10:00,220
one is less than four.

122
00:10:00,250 --> 00:10:04,960
We continue, of course, so we did that person plus plus.

123
00:10:04,960 --> 00:10:09,070
So we're going to go into here now top in position.

124
00:10:09,100 --> 00:10:11,050
You notice it just was a three.

125
00:10:11,050 --> 00:10:13,180
It gets reset to zero.

126
00:10:13,660 --> 00:10:20,950
Top position is now zero again and we can start cycling through our toppings for this person, which

127
00:10:20,950 --> 00:10:21,970
is person one.

128
00:10:22,330 --> 00:10:24,400
Technically, the second person, right?

129
00:10:24,400 --> 00:10:27,790
Because we already did the first person, that person was considered person zero.

130
00:10:28,960 --> 00:10:37,360
So we cycled through the toppings again, incrementing as we go, we say person one chose topping B

131
00:10:37,360 --> 00:10:39,880
because topping B is the position zero right.

132
00:10:40,930 --> 00:10:43,090
Increment it to the next topping now.

133
00:10:43,090 --> 00:10:50,000
Person one just topping M now person one chose topping we we go up here.

134
00:10:50,030 --> 00:10:51,760
Three is not less than three.

135
00:10:52,570 --> 00:10:54,550
So now we're done with the inner loop.

136
00:10:54,550 --> 00:11:00,280
We go to this last line of the outer loop and we say Person one has paid.

137
00:11:00,820 --> 00:11:03,580
Now we go to back to the outer loop, we go to the next person.

138
00:11:04,420 --> 00:11:09,400
We are now on person number two, which we consider the third person, right because we did zero and

139
00:11:09,400 --> 00:11:10,150
one already.

140
00:11:10,150 --> 00:11:14,530
And now we're on the third person, but we're calling it person two because it started zero.

141
00:11:15,400 --> 00:11:21,310
We go here and start doing the toppings for person two, so we reset top in position to zero.

142
00:11:24,290 --> 00:11:33,350
Person to choose this top and be person two to chose topping in person, to chose to be done with this

143
00:11:33,350 --> 00:11:33,720
loop.

144
00:11:33,740 --> 00:11:36,740
Person to paid person three.

145
00:11:36,980 --> 00:11:39,680
We go in here person three.

146
00:11:39,740 --> 00:11:41,800
So we in Typekit position back to zero.

147
00:11:41,810 --> 00:11:48,950
We say person three chose topping be person three chose topping in person.

148
00:11:48,950 --> 00:11:50,960
Three chose topping the.

149
00:11:51,590 --> 00:11:53,780
We're done with this person to be paid.

150
00:11:54,140 --> 00:11:55,040
We go back up here.

151
00:11:55,040 --> 00:12:00,860
We say person is for him is for less than four line like this.

152
00:12:00,860 --> 00:12:02,060
Four is for less than four.

153
00:12:02,100 --> 00:12:02,960
No, it's not.

154
00:12:03,860 --> 00:12:11,060
We're now done with our outer loop and we now go past this closing bracket and we just do it here.

155
00:12:11,060 --> 00:12:11,980
Return zero.

156
00:12:11,990 --> 00:12:13,400
We are now finished.

157
00:12:14,850 --> 00:12:21,780
So I'm going to escape out of here, go into the visual studio where I have this code.

158
00:12:22,320 --> 00:12:24,660
I am going to compile this code

159
00:12:28,680 --> 00:12:29,940
and I'm just going to say

160
00:12:32,280 --> 00:12:35,430
NFL easy.

161
00:12:38,780 --> 00:12:44,780
I will now run an AFL AFC and we can check out the results, so let's bring this up.

162
00:12:46,460 --> 00:12:51,200
I'm going to scroll up a bit and I bring this down just a bit.

163
00:12:54,240 --> 00:12:58,020
So as you can see here, oops, sorry about that.

164
00:12:59,160 --> 00:13:01,620
You can see that we said.

165
00:13:04,180 --> 00:13:10,510
Person zero showstopping, be person zero, just tapping in person, zero showstopping V. I didn't put

166
00:13:10,510 --> 00:13:14,980
a space between those, I should probably have done that.

167
00:13:14,990 --> 00:13:16,690
That would be a lot nicer.

168
00:13:19,050 --> 00:13:20,820
So let's say.

169
00:13:22,580 --> 00:13:27,530
We do that, and then we put like a comma or something like that.

170
00:13:28,070 --> 00:13:30,860
Let's go ahead and say this and make the output nicer.

171
00:13:30,980 --> 00:13:35,690
So I'm going to compile again and run again.

172
00:13:36,200 --> 00:13:36,620
All right.

173
00:13:36,650 --> 00:13:37,760
That looks a little nicer.

174
00:13:39,130 --> 00:13:44,290
Actually, person zero, let's put a space here as well, because that looks still looks kind of gross.

175
00:13:47,140 --> 00:13:47,540
All right.

176
00:13:47,560 --> 00:13:51,710
Here we go, so person zero, just tapping the person's, you know, just tapping in person through

177
00:13:51,730 --> 00:13:57,580
just tapping we and we say persons who are still not a space there should put a space there, right?

178
00:13:57,820 --> 00:13:58,360
So.

179
00:14:01,960 --> 00:14:07,690
Let's go ahead and do that, make all of our little corrections, so the outfit looks nice and then

180
00:14:07,870 --> 00:14:12,230
you notice that says each person chooses these toppings, then they pay.

181
00:14:12,790 --> 00:14:17,800
Then the next person chooses their toppings, then they pay, then the next person chooses their toppings

182
00:14:17,800 --> 00:14:19,090
and they pay and so on.

183
00:14:19,090 --> 00:14:26,110
Until all four people starting at zero going to one and two, then three, they all get to choose their

184
00:14:26,110 --> 00:14:31,060
toppings and pay in the correct order in which they should be moving through the sandwich shop.

185
00:14:31,090 --> 00:14:31,390
Right?

186
00:14:34,280 --> 00:14:38,280
OK, so pretty neat concept.

187
00:14:38,300 --> 00:14:45,860
You can also loop some other things, though, so we can have a for loop inside of a while loop and

188
00:14:45,860 --> 00:14:48,260
a while loop inside of a while loop.

189
00:14:48,620 --> 00:14:52,550
So let's go ahead and check out some of those examples, too.

190
00:14:53,600 --> 00:14:57,710
So I'm going to go up here and I'm going to go ahead and just delete this.

191
00:14:58,490 --> 00:15:01,490
And then I'm going to say I'm going to put a while loop.

192
00:15:01,490 --> 00:15:05,480
So I'll just say, let's say and.

193
00:15:07,800 --> 00:15:24,120
The number of people equals four, and I will just say that we will do some sort of while loop where

194
00:15:24,120 --> 00:15:27,780
we can continue getting some input or something like that.

195
00:15:27,780 --> 00:15:32,370
So I could say, um, let's say.

196
00:15:33,970 --> 00:15:35,030
Uh.

197
00:15:36,560 --> 00:15:38,720
A name, right, let's do like a string.

198
00:15:39,440 --> 00:15:42,380
Name equals.

199
00:15:43,060 --> 00:15:44,290
We'll just say a string name, right?

200
00:15:44,300 --> 00:15:47,240
No industry I'll get and then what we will say after that.

201
00:15:47,920 --> 00:15:52,190
We all see in to name.

202
00:15:53,300 --> 00:15:57,320
And then what we will do is we will say.

203
00:16:01,940 --> 00:16:14,660
While name not equal to quit and what we will do is.

204
00:16:16,590 --> 00:16:23,460
We will add the name, let's see, let's see, we'll just see out.

205
00:16:29,880 --> 00:16:34,590
So we could say see out name

206
00:16:38,130 --> 00:16:39,780
and then we'll just say.

207
00:16:43,320 --> 00:16:44,190
For.

208
00:16:48,100 --> 00:17:02,980
And equals zero, I is less than and we will just say a number of people plus plus and we will just

209
00:17:02,980 --> 00:17:13,480
say in here that this is just kind of some random thing, you know, some hypothetical situation, but

210
00:17:13,480 --> 00:17:15,310
we'll just say our name.

211
00:17:20,520 --> 00:17:23,970
Helps person

212
00:17:26,580 --> 00:17:27,030
I.

213
00:17:28,430 --> 00:17:29,030
How about that?

214
00:17:30,290 --> 00:17:41,660
And then we will do a space and something like that, and then we will just see in and we will get another

215
00:17:41,660 --> 00:17:42,710
name right?

216
00:17:45,040 --> 00:17:48,130
So this is just someone that maybe works somewhere.

217
00:17:48,550 --> 00:17:56,650
Maybe the person at the shop counter what he does in this time, though, is it's just a bunch of people

218
00:17:56,650 --> 00:17:57,460
coming by.

219
00:17:57,880 --> 00:18:03,250
Let's just say that this is like people coming to get vaccinated for COVID 19.

220
00:18:03,250 --> 00:18:06,070
It seemed kind of appropriate for this point in time.

221
00:18:06,070 --> 00:18:08,080
Where am making this course?

222
00:18:08,080 --> 00:18:15,010
At least, you know, it is, as you can see, June and twenty twenty one.

223
00:18:15,010 --> 00:18:18,190
So we still have a little bit of a COVID problem now.

224
00:18:18,850 --> 00:18:27,070
So let's just say that there's this guy or there's multiple people and they help four people each.

225
00:18:27,520 --> 00:18:35,740
So we have some qualified people giving vaccinations and each one of these people, we're going to enter

226
00:18:35,740 --> 00:18:41,560
their name and they're going to help their assigned people, which will be like person one person to

227
00:18:41,560 --> 00:18:42,910
person to person or.

228
00:18:44,820 --> 00:18:52,170
So let's go ahead and compile this and run this, it's still called nested for.

229
00:18:52,590 --> 00:18:57,300
But we can, of course, uh, rename that.

230
00:18:57,660 --> 00:19:03,730
We can do actually do something in here while I can say move nested for.

231
00:19:03,750 --> 00:19:05,830
And I will now call it moving it.

232
00:19:05,850 --> 00:19:09,030
You can actually change the name or you can move it to a different location.

233
00:19:09,030 --> 00:19:16,320
But I'm going to do is change the name in this same directory, and I'm just going to call this nested.

234
00:19:17,190 --> 00:19:20,040
I call it Nest Wild for CBD.

235
00:19:20,160 --> 00:19:24,480
So now I move that it says that this is deleted here.

236
00:19:24,480 --> 00:19:28,410
But if but we could totally open it up and it would be there.

237
00:19:30,430 --> 00:19:37,090
So I'm scrolling through all of the gross stuff that I have in this single directory, which should

238
00:19:37,090 --> 00:19:38,020
be organized.

239
00:19:38,110 --> 00:19:41,350
You should organize it in a nice way and keep it like me.

240
00:19:42,100 --> 00:19:48,510
So now I open this and it's totally fine and I actually can compile this and, you know, just allow

241
00:19:48,520 --> 00:19:49,980
for show.

242
00:19:50,380 --> 00:19:57,970
Well, for Dot C or easy so I can compile that.

243
00:19:59,860 --> 00:20:00,300
Oops.

244
00:20:00,310 --> 00:20:02,410
We get a lot of.

245
00:20:05,680 --> 00:20:07,660
Errors here, so.

246
00:20:09,770 --> 00:20:12,530
Let's see what the problem is.

247
00:20:13,940 --> 00:20:15,800
See, that name helps, person.

248
00:20:18,270 --> 00:20:19,710
It's not derived.

249
00:20:21,470 --> 00:20:23,120
From we put the wrong

250
00:20:26,120 --> 00:20:27,290
operators here.

251
00:20:28,670 --> 00:20:33,050
So I actually put the wrong operators throughout this entire expression.

252
00:20:33,350 --> 00:20:35,580
So let's go ahead and change that.

253
00:20:38,300 --> 00:20:40,700
And it needs to be changed here as well.

254
00:20:41,150 --> 00:20:48,410
So I put the input operator four instead of the the output one.

255
00:20:48,410 --> 00:20:54,290
So now that is changed, I'll go ahead and save this and that should fix it.

256
00:20:56,110 --> 00:21:02,440
All right, that fixes it, so I'm going to go ahead and run it now, so you notice nothing prints out

257
00:21:02,440 --> 00:21:05,350
because we're just asking for the name without printing anything out.

258
00:21:05,800 --> 00:21:06,760
The initial time.

259
00:21:07,270 --> 00:21:11,350
So I'm going to go ahead and put a name, and I'm just going to say Bob.

260
00:21:12,610 --> 00:21:14,950
And so you notice that it prints out Bob.

261
00:21:14,950 --> 00:21:17,710
So I entered Bob and it says, OK, well, I'm Bob.

262
00:21:17,830 --> 00:21:19,090
Bob helps person zero.

263
00:21:19,090 --> 00:21:20,200
Bob helps person one.

264
00:21:20,200 --> 00:21:21,610
Bob helps person to bob.

265
00:21:21,610 --> 00:21:22,660
That was person three.

266
00:21:24,750 --> 00:21:31,530
I did not do another in line after this, so it's kind of gross, but now I can say, you know, Mary

267
00:21:31,530 --> 00:21:35,010
or something like that, and it says Mary Mary helps all of these people.

268
00:21:35,640 --> 00:21:40,530
So you notice that what we're doing is it's waiting for us to enter a new name and it's going to keep

269
00:21:40,530 --> 00:21:44,100
asking for a name over and over until we do quit.

270
00:21:44,100 --> 00:21:49,530
And each time we enter a name, it is thing going to run this inner for loop, and it's going to say

271
00:21:49,530 --> 00:21:54,020
that that person helps each of these other people.

272
00:21:54,030 --> 00:21:58,680
You know, a number of people person, zero person, one person, two in person, three.

273
00:21:59,080 --> 00:21:59,430
Right.

274
00:21:59,440 --> 00:22:00,930
So each of those four people.

275
00:22:01,680 --> 00:22:05,100
So I see Jeff now and it says, OK, we're on Jeff.

276
00:22:05,100 --> 00:22:06,480
Jeff helps person zero.

277
00:22:06,480 --> 00:22:07,620
Jeff helps person one.

278
00:22:07,860 --> 00:22:13,380
And it's just going to keep going until we Typekit, in which case the program quits, right?

279
00:22:15,580 --> 00:22:20,470
So just wanted to give another example there that you can put the four inside of the wall and you can

280
00:22:20,470 --> 00:22:26,290
also put a while inside of me while here as well, I don't think that I need to demonstrate that.

281
00:22:26,290 --> 00:22:27,640
I think you can figure that out.

282
00:22:27,640 --> 00:22:32,440
You just simply put another well in there and you should be able to trace it on your own.

283
00:22:34,030 --> 00:22:39,730
But I think that I'm going to leave off the lecture at this point because in the next lecture, we're

284
00:22:39,730 --> 00:22:42,760
going to have to get into looking into.

285
00:22:44,210 --> 00:22:52,370
Not just a raise, but we're going to look into matrices which are two dimensional arrays.

286
00:22:54,450 --> 00:22:57,840
At least we're going to be looking at two dimensions, and they're not going to be looking at anything

287
00:22:57,840 --> 00:22:59,010
more than two dimensions.

288
00:23:00,030 --> 00:23:07,130
But we're going to need to use nested loops to be able to iterate over these two dimensional arrays,

289
00:23:07,140 --> 00:23:11,610
and so I wanted to introduce the concept of nested loops so you could solidify that.

290
00:23:12,090 --> 00:23:16,860
And then afterwards, you would understand more when we're introducing the matrices.

291
00:23:17,520 --> 00:23:22,290
So with that, I will leave you to it, go ahead and practice some of this stuff here.

292
00:23:22,680 --> 00:23:28,050
Once we get into the matrices, I will have some more practice problems for you to get used to all this.

293
00:23:28,740 --> 00:23:32,220
But until then, I will see you in the next lecture.
