Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:01,140 --> 00:00:08,400
Previously I showed you that in order to get the index off an item you can use the index method.
1
2
00:00:08,430 --> 00:00:10,350
Now how can we do the reverse?
2
3
00:00:10,350 --> 00:00:15,180
How can we get an item given its index?
3
4
00:00:15,380 --> 00:00:21,590
Well for that we need to look one more time at the least of attributes that you can apply to the
4
5
00:00:21,590 --> 00:00:22,400
list.
5
6
00:00:22,670 --> 00:00:29,080
And I know that we can use the __getitem___ method.
6
7
00:00:29,170 --> 00:00:29,430
Okay.
7
8
00:00:29,450 --> 00:00:36,710
I know I told you earlier that these methods rarely you're going to use and in fact we don't need
8
9
00:00:36,770 --> 00:00:44,390
these methods for what I'm going to do now, but let me explain why in just a bit you'll understand,
9
10
00:00:44,390 --> 00:00:46,850
and this is a very secret of Python.
10
11
00:00:47,540 --> 00:00:55,710
So let me go ahead and use __getitem__ with double underscores.
11
12
00:00:55,880 --> 00:01:01,640
And of course it's a method so it needs this round brackets parentheses.
12
13
00:01:01,760 --> 00:01:10,620
So let's try to get the item with index 1.
Which would that be? Well, 8.8.
13
14
00:01:10,620 --> 00:01:16,830
Not the secret is that you don't have to use that ugly method there.
14
15
00:01:17,300 --> 00:01:22,940
With those double underscores, all you have to do is use this syntax.
15
16
00:01:22,940 --> 00:01:26,600
So call the variable name like that.
16
17
00:01:27,110 --> 00:01:32,280
And then add open and closing square brackets and then inside them just enter the index.
17
18
00:01:32,610 --> 00:01:40,450
And that will give you the value, the item for that index again even though you're doing this, Python
18
19
00:01:40,480 --> 00:01:49,400
on the background actually is calling this method and is passing this item, this value as an input for
19
20
00:01:49,400 --> 00:01:51,210
that methods.
20
21
00:01:51,230 --> 00:01:58,070
So this is actually what's going on on the ground but Python lets you do it in a better fashion.
21
22
00:01:58,300 --> 00:01:59,330
Like this in here.
2281
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.