1
00:00:04,680 --> 00:00:08,760
Alright, so let's go over the solution
to the unpacking challenge, we talked

2
00:00:08,760 --> 00:00:13,860
about in the last video. Currently, each
of the items in our albums list is a tuple.

3
00:00:13,860 --> 00:00:18,390
When we iterate over albums, we get
each tuple in turn, and we can unpack it

4
00:00:18,390 --> 00:00:24,800
at the same time. So the change is to
line ten, so let's make a change to line ten.

5
00:00:24,800 --> 00:00:29,060
So what I'm going to do is delete
the album part of the for album

6
00:00:29,060 --> 00:00:36,140
statement, and instead, what I'm going to
do is type in there, for name comma artist

7
00:00:36,140 --> 00:00:42,480
comma year, then leave the rest of
the line as it was, which was in albums.

8
00:00:42,480 --> 00:00:51,460
If we run the program now, we get the
same output as we did previously.

9
00:00:51,460 --> 00:00:55,940
So that's one solution. So you may have left
line ten alone, and instead, unpacked the

10
00:00:55,950 --> 00:01:00,780
tuples on the next line. What I'm going
to do is paste in this code, right after

11
00:01:00,780 --> 00:01:05,760
the existing code. Alright, so I'll come
down here and I'll paste in the code.

12
00:01:05,760 --> 00:01:09,420
So this will produce the same output. So
we'll run that firstly, to confirm that

13
00:01:09,420 --> 00:01:15,750
it is the case, and you can see we've got
the identical output there. Now it's not

14
00:01:15,750 --> 00:01:21,500
quite as efficient, compared to the
previous loop - the one starting on line ten -

15
00:01:21,500 --> 00:01:26,200
but it has the advantage that you also
have the original tuples available.

16
00:01:26,200 --> 00:01:30,960
Each time around the loop, you can refer to
album, if you need to. Most of the time,

17
00:01:30,960 --> 00:01:35,440
though, you should use the first loop,
where we unpack the tuples on line ten.

18
00:01:35,440 --> 00:01:38,940
Alright, so as well as showing you how
to unpack tuples, we've also seen

19
00:01:38,940 --> 00:01:44,370
that the items in a sequence, can be a
sequence type themselves. So here, our

20
00:01:44,370 --> 00:01:50,010
albums list contains tuples. Notice that
the list is homogeneous. All of the items

21
00:01:50,010 --> 00:01:54,900
it contains are of the same type. In other
words, here, they're all tuples. The tuples

22
00:01:54,900 --> 00:02:00,020
are heterogeneous - each one contains two
strings and an int.

23
00:03:03,640 --> 00:03:08,340
In the next version of this program, we'll make a change to add some songs to the albums.

24
00:03:08,340 --> 00:03:11,420
See you in the next video.

