1
00:00:00,000 --> 00:00:03,990
The simplest form of a loop in Python is the while loop.

2
00:00:04,000 --> 00:00:11,990
So, let's make a working copy of while.py, while-working.py, and we'll go ahead

3
00:00:12,000 --> 00:00:13,990
and open our working copy there.

4
00:00:14,000 --> 00:00:17,990
The while loop is controlled with the while keyword, which we can see here, and

5
00:00:18,000 --> 00:00:20,990
then there is an expression.

6
00:00:21,000 --> 00:00:24,990
So, the expression gets evaluated, and if the expression is true, then the code

7
00:00:25,000 --> 00:00:28,990
inside the loop, the suite, is executed.

8
00:00:29,000 --> 00:00:33,990
After that code is executed, the expression is evaluated again, and if it's still

9
00:00:34,000 --> 00:00:36,990
true, the code gets executed again.

10
00:00:37,000 --> 00:00:42,990
This continues until the expression is evaluated as false, and then the execution

11
00:00:43,000 --> 00:00:44,990
begins after the while loop.

12
00:00:45,000 --> 00:00:49,990
So, let's go ahead and run this, and there is our Fibonacci series.

13
00:00:50,000 --> 00:00:57,990
So, this expression is b<50, so as long as the result there is <50, the while

14
00:00:58,000 --> 00:00:58,990
loop will continue.

15
00:00:59,000 --> 00:01:04,990
So, if I were to increase this to say 150, save that, and run it, then we get a few

16
00:01:05,000 --> 00:01:08,990
more numbers out there in the Fibonacci series.

17
00:01:09,000 --> 00:01:13,990
So, while is the simplest form of loop in Python, and you can see all it does is

18
00:01:14,000 --> 00:01:15,990
it evaluates this expression.

19
00:01:16,000 --> 00:01:20,990
As long as the expression is true, it executes the code in the while loop, and as

20
00:01:21,000 --> 00:01:23,990
soon as the expression is not true, the loop ends.

21
00:01:24,000 --> 00:01:34,000
So, that's the while loop in Python.

