Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,420 --> 00:00:04,250
You saw that looping through a list is straight forward.
1
2
00:00:04,260 --> 00:00:06,040
You just do it like that.
2
3
00:00:06,060 --> 00:00:10,160
However if you have a dictionary it this a bit more complex.
3
4
00:00:10,650 --> 00:00:18,000
Again you do for pick a variable name in the dictionary you want to iterate.
4
5
00:00:18,120 --> 00:00:23,130
But here you want to specify what you want to iterate.
5
6
00:00:23,160 --> 00:00:30,080
Do you want to iterate over items, keys, or values.
If you want to iterate over items, you'd apply
6
7
00:00:30,180 --> 00:00:31,320
.items(): there.
7
8
00:00:31,360 --> 00:00:35,950
Don't forget the colon and print(grades).
8
9
00:00:36,090 --> 00:00:36,810
See what .
9
10
00:00:40,020 --> 00:00:44,870
So you get these items printed out as a tuple.
10
11
00:00:44,880 --> 00:00:48,460
These are tuples.
11
12
00:00:48,960 --> 00:00:59,690
So the key and the value for each iteration.
If you wanted the keys instead it, you just write keys there.
12
13
00:01:00,110 --> 00:01:08,240
And if you wanted the values you just write .values(): and you get the values, that's how you iterate
13
14
00:01:08,300 --> 00:01:09,260
over dictionaries.
1307
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.