1
00:00:01,690 --> 00:00:09,140
So you learn that a for loop iterate through a container which could be a list, or a string, or a tuple.

2
00:00:09,250 --> 00:00:14,140
And the loop will terminate when the container is exhausted.

3
00:00:14,140 --> 00:00:19,610
So for example it prints out one, two, and three.
And when there are no more items

4
00:00:19,630 --> 00:00:20,850
the loop ends.

5
00:00:21,370 --> 00:00:32,950
So a full loop runs until a container is exhausted and a while loop a while loop runs as long as this

6
00:00:32,950 --> 00:00:34,030
condition is true.

7
00:00:38,330 --> 00:00:42,470
Let me execute that and see what is going to happen.

8
00:00:42,470 --> 00:00:49,760
So you will see that 1 is being printed out all the time.

9
00:00:49,940 --> 00:00:56,210
So if I scroll up here I will not be able to find where the starting point was because there's a million

10
00:00:56,210 --> 00:01:00,550
ones now being printed out there every split of a second.

11
00:01:00,590 --> 00:01:09,260
So what's going on here is that a while loop, while is a keyword, and then that is followed by a condition.

12
00:01:09,290 --> 00:01:13,820
In this case the condition is that A is greater than zero which is true.

13
00:01:13,970 --> 00:01:15,520
So A is actually 3.

14
00:01:15,560 --> 00:01:17,450
That means this condition is true.

15
00:01:18,050 --> 00:01:27,060
And as long as this condition is true, this will be printed out, so under the while loop you can have

16
00:01:27,120 --> 00:01:30,630
as many actions operations as you want.

17
00:01:30,630 --> 00:01:35,170
For example let me interrupt this with control C on your terminal.

18
00:01:35,720 --> 00:01:41,250
And then add another line here print2, save, execute.

19
00:01:41,280 --> 00:01:43,070
So 1 2, 1 2, 1 2, 1 2, 1 2

20
00:01:43,170 --> 00:01:44,240
is being printed out.

21
00:01:45,850 --> 00:01:47,920
Okay I'll interrupt that.

22
00:01:48,080 --> 00:01:51,180
Not the rate that these numbers are being printed out

23
00:01:51,190 --> 00:01:52,980
depends on your computer.

24
00:01:52,980 --> 00:01:54,100
Processor speed.

25
00:01:54,640 --> 00:01:58,740
So the faster your processor, the faster you will get these action here,

26
00:01:58,740 --> 00:02:01,540
these operations being executed.

27
00:02:01,630 --> 00:02:09,520
Now of course this will always forever be true because it's a just a static declaration of a variable

28
00:02:09,520 --> 00:02:10,090
here.

29
00:02:10,090 --> 00:02:15,570
So no one is changing it here, therefore of a condition will always be true.

30
00:02:15,610 --> 00:02:21,710
You can see inside Python when you check something like 3 is greater than 0 you get true.

31
00:02:21,730 --> 00:02:28,110
So this is basically while True, and you will sometimes see it like that.

32
00:02:28,110 --> 00:02:29,860
So just delete the first line.

33
00:02:33,040 --> 00:02:35,360
Exit here, execute the code again.

34
00:02:36,500 --> 00:02:40,140
So again the same thing happens because true is always true.

35
00:02:41,900 --> 00:02:46,020
However, this is not how while loops are used in real world.

36
00:02:46,250 --> 00:02:50,990
It's meaningless to check if true is true and print out something all the time.

37
00:02:51,590 --> 00:02:55,570
So let me go ahead and explain while loops in a better example in the next video.

