Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:12,030 --> 00:00:19,160
Aaron and welcome in this new video in this video we're going to talk about the loop for the loop for
2
00:00:19,400 --> 00:00:28,430
is very useful in Python and you really need to master it because it will allow us to iterate something
3
00:00:28,700 --> 00:00:32,570
on a list or a sequence or dataframe.
4
00:00:34,070 --> 00:00:39,830
It will really allow us to iterate something on a lot of objects.
5
00:00:39,950 --> 00:00:42,410
So it's very necessary to master it.
6
00:00:43,280 --> 00:00:48,320
For example, if a quit lists name sequence.
7
00:00:54,680 --> 00:01:06,400
And I want to create a loop for just to print each element of the list one by one I will use as a full
8
00:01:06,410 --> 00:01:07,010
operator.
9
00:01:08,120 --> 00:01:14,080
Then you need to put the name of the new variable.
10
00:01:14,090 --> 00:01:20,900
So as you want, for example, you can put it in, but you put what you want.
11
00:01:21,170 --> 00:01:31,940
You just need to understand that this virtual item will represent one by one, each element of this
12
00:01:31,940 --> 00:01:32,540
sequence.
13
00:01:33,920 --> 00:01:36,950
So for item in sequence.
14
00:01:37,100 --> 00:01:48,890
So because we need to tell Python in which object you want to take the item, then you put a double
15
00:01:48,890 --> 00:01:49,250
point.
16
00:01:50,390 --> 00:01:57,110
You go to the line and there is also an indentation because you need to tell to Python.
17
00:02:00,290 --> 00:02:09,500
That's the following year is for the loophole and notes in the normal code.
18
00:02:11,630 --> 00:02:15,260
So you put a prince or item.
19
00:02:18,050 --> 00:02:25,590
It is a really simple example, but in the loophole you can put pretty that you want.
20
00:02:25,640 --> 00:02:32,510
So for example, if you want to do the scrap of each eye, then you can do it like this.
21
00:02:32,510 --> 00:02:37,880
So as you can see, it's very powerful to master the loophole.
22
00:02:38,090 --> 00:02:43,460
So it's essential to muster it to work in algorithmic trading.
23
00:02:45,800 --> 00:02:51,890
Now let me show you how to do a loop in a range of data.
24
00:02:52,370 --> 00:03:01,430
So for item in and then we are going to use the ring function.
25
00:03:02,210 --> 00:03:06,170
The winch function will allow us to
26
00:03:09,590 --> 00:03:17,500
take all the integral number from zero to here six, for example.
27
00:03:17,510 --> 00:03:24,020
So if a print item, you can see that you have zero one two three four five.
28
00:03:24,740 --> 00:03:30,500
But if you want to begin, for example, two six, you can do it.
29
00:03:31,880 --> 00:03:38,180
Just turning to Python that we begin from six to 10.
30
00:03:42,460 --> 00:03:52,000
So it is really easy to use, and it is the most common way to use a for loop.
31
00:03:54,550 --> 00:04:07,150
And there exists another way to create a loop, but a little bit more complex, but it's at least necessary
32
00:04:07,390 --> 00:04:14,350
to know that this way exists because it is a way to simplify your code.
33
00:04:14,560 --> 00:04:27,550
And sometimes when you work with a lot of good, it is very some trick like this to have less good to
34
00:04:27,700 --> 00:04:28,480
work with it.
35
00:04:30,010 --> 00:04:37,030
So we are going to see how to create a loop in a list.
36
00:04:37,570 --> 00:04:42,520
So to do it, you need to put first.
37
00:04:43,690 --> 00:04:53,560
What we are going to do in the lists this spot and then you need to put four item in range.
38
00:04:55,590 --> 00:05:07,150
Then, Hugh, it's very important to understand that we don't need to put the double point because we
39
00:05:07,150 --> 00:05:11,600
need to write this in only one line.
40
00:05:11,620 --> 00:05:25,210
So Python has no need to seek the double plain because this syntax is written only in one line.
41
00:05:27,010 --> 00:05:35,770
So if I learned if I runs a could, you can see that I have exactly the same thing as before, except
42
00:05:35,770 --> 00:05:38,860
that here we need to begin at one.
43
00:05:42,400 --> 00:05:50,530
Again, I will only advise you to work with the loophole in your way to weeding Must-Reads.
4409
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.