Hey, in this lecture you'll learn about loops and loops are very important.
They are one of the fundamental building blocks of the Python programming language
and of every other programming language as well because loops are crucial.
So what are loops? Well loops are basically the way that allows you to execute the
statement multiple times, so what does that mean? Let's say you have a bunch of
files, text files and you want to insert a certain string inside each of these
text files, so you'd have to open those text files in Python by writing the
Python code that corresponds to opening a file and then you insert that string
inside the file and close the file and save it, so there is some code that does
this opening and inserting the text and closing the file and if you had 100
files you'd have to execute that code 100 times so you'd come up with let's
say 100 lines of code but that doesn't sound very efficient so that's what loops
are for. So a productive way to solve the problem that I just mentioned would be
to create a list of these files so Python lists all of the file names and
then you would use a loop to iterate through this list of file names and a loop
would do all that in just a few lines of code and there are two kinds of loops in
Python, there is a for loop and a problem for example that I just mentioned would
be solved using a for loop and we also have the while loop. A while loop does
also repeatedly execute a statement that you give, that you write and it
executes it as long as the given conditional true, so let's say you have a user that
is trying to login in your web app and while he keeps entering their own
password, you'd continue executing a statement that would reject his login to
your system, so while the password is wrong reject the user, something like that.
So that's about the definition of the for loop and the while loop. In our
next lecture I'll show you the syntax of the for loop and by also looking at an example,
so see you in the next lecture.