So one thing you can do with loops is nest them.
So let's see an example of what I mean.
So let's say we have contest in Max goes to five
and we say.
He calls to 1 is less than or equal to Max an.
Plus plus
and then we say zero out
interation is
I
and then we say 4 inch J goes to 1.
So we're not using or using j.
Because I I could be used inside of this in J 4 but we don't want that to happen so we have to use a
different variable here.
Less than or equal to max Juniperus us and same thing iteration J.
Is just
and run this and see what it outputs.
So you see Aerschot I is equal to 1.
And then you say that he see iteration J from 1 to 5 K so it only did 1 iteration I 4 5 iteration James
or 5 iteration js for one iteration.
That makes sense.
And then so see here iteration equals 2 and we do iteration J 2 from 1 to 5.
And the same thing with three went to 5 for J eyes for 1 to 5.
J.
Narration 5 in 1 to 5 for J.
So you see we do five iterations of J for each iteration of I.
So you may ask why is this useful.
Well we'll see later for much harder problems.
Having multiple loops really does help and really solves some much more interesting problems than just
having sort of a linear non nested loop and I'll show you some examples of that in the practice problems.
Lecture this section.