Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,660 --> 00:00:06,020
Do dictionaries have the same index system as lists and strings?
1
2
00:00:06,050 --> 00:00:07,380
Let's find that out.
2
3
00:00:07,380 --> 00:00:10,770
I have this dictionary here on my Python Shell.
3
4
00:00:11,190 --> 00:00:12,080
Student grades.
4
5
00:00:12,090 --> 00:00:17,650
So let's try to get the second item maybe.
5
6
00:00:18,670 --> 00:00:29,740
Nope, it's says KeyError: 1 which means that the dictionary doesn't have a key named 1.
6
7
00:00:29,820 --> 00:00:32,730
So what keys does the dictionary have?
7
8
00:00:32,800 --> 00:00:35,290
Maybe the "Sim" key.
8
9
00:00:35,910 --> 00:00:41,910
Yes, so dictionaries instead of integers they have keys as indexes.
9
10
00:00:41,910 --> 00:00:48,750
So a least would be access, the items of the list would be accessed via integers which start from
10
11
00:00:48,750 --> 00:00:49,940
zero.
11
12
00:00:49,940 --> 00:00:56,190
An end to the last item of the list, the index of the last item of the list. With dictionaries
12
13
00:00:56,190 --> 00:01:01,410
this is different as you can see and this is actually what makes dictionaries a dictionary.
13
14
00:01:01,440 --> 00:01:04,080
Let's see another example of how useful this is.
14
15
00:01:04,080 --> 00:01:11,100
Let's say you have this dictionary English the Portuguese.
It's a real human dictionary.
15
16
00:01:11,100 --> 00:01:13,690
You have some words there.
16
17
00:01:14,150 --> 00:01:23,240
Let's say "rain", "chuva" in Portuguese and "sun" will be "sol."
17
18
00:01:24,220 --> 00:01:28,710
Sorry I've got a typo there, quote.
18
19
00:01:29,490 --> 00:01:37,250
So now if you want the Portuguese version of sun, you write that and that will give you that version.
19
20
00:01:37,530 --> 00:01:42,060
So having integers s indexes in this case would be very useless.
20
21
00:01:42,060 --> 00:01:48,420
So every use case has its own data structure to be used in Python.
2062
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.