So now we're going to talk about what we're trying to accomplish with

a loop, right?

We're trying to, we know how they mechanically work but

what are we looking for?

What if we're looking for the largest value or

checking to see if 42 is a member of a set or something?

Or looking for the largest letter, like the max function?

And so we're going to construct loops sort of with an idea of doing something to each

value in the set that we're iterating through.

And then coming up with some kind of result.

And the pattern that we're going to do is we're going to write a for loop.

And actually, in this next two segments, I'm going to do the exact same for loop.

But we're going to do something before the loop starts,

set some variables to initial values.

And then we're going to do something to every one of the values in our list.

And then, we don't know what the largest value is while the loop is running.

And our goal is, when the loop finally finishes, that we have something.

Whether it's the maximum, the minimum, the average, the total,

how many things there are, how many things match.

And so, the iterations are getting us closer to knowing the answer.

But they don't instantly know the answer, so we we have to work towards the answer.

By setting something and then sort of checking it a bunch of times.

And then we have sort of have absolute, the truth comes out at the bottom.

And you'll see this in a second.

So here's the little loop that we're going to do.

And I'm going to do this over and over and over again, and these numbers,

you're going to get tired of these numbers.

For some variable, iteration variable in 9, 41, 12, 3, 74, 15.

We print out a before.

So we're going to do something before the loop.

We're going to do something during the loop and after the loop.

Right now, I'm just printing everything out.

So you kind of see how the loop kind of works, okay?

Okay, so here's a little problem.

I'm going to show you a number of numbers and maybe it'll be a million or

maybe it'll be 6, I don't know.

But you don't know how many I'm going to show you.

And I want you to tell me when it's all said and done what the largest number is.

And it's not going to be too hard.

But imagine that you had to do this for a million numbers as a human being.

That you were just sitting there and numbers going by and by and by and by.

How would your brain truly solve the problem?

So here, ready?

Here goes some numbers.