So let's continue working with our lists. And I want us to try to write a program
that will simply print out the high activity days. Now, what you see on my screen
is a list of login attempts per day.
So let us write a program
that will go through this list and then print out
the high activity days.
However,
to determine what a high activity would be,
let's say login attempts that are 10 or more.
OK?
So
to do this,
let's create a variable that will store the high activity day. So I can say hi
and then underscore activti
underscore
days.
OK?
Now this is going to be equal to
let's say attempts, OK?
We want to create a full loop that's going to go through the list. OK. So
we have our brackets in here and then I can say attempt,
OK?
For, remember now, for attempt
in
where are we checking?
The number of attempts is going to be in the login attempts list. So
I'm gonna say in the login
attempt
and now we haven't talked about this yet. But you can also include an if statement
directly inside of a for loop. So
we want to create a loop that's going to go through a list and then if the attempt
is 10 or more,
we're gonna print out a high activity day. So attempt for attempt in login attempts.
And now if what the attempts
is greater than, or equal to 10,
you got that.
Ok.
So now what should happen?
Let's simply print
and then in brackets,
we can say something like hi
uh activity uh days,
colon
and then
comma
high
underscore activity days.
So now if I run the program
and there you go, the high activity activity days, we have 1012, 15 and 20.
So this is how we can run a full loop to
go through our list and then print or do something else.
So I'm going to provide you with an exercise, a challenge in the very next video.
Please go through it
and attempt to answer the questions.
Thank you for watching the video. I will see you in the next class.