1
00:00:05,020 --> 00:00:09,320
Let's go over the solution to the
challenge I discussed in the last video.

2
00:00:09,320 --> 00:00:12,680
How did you get on with it though? Did you
manage to change the code, to let the

3
00:00:12,680 --> 00:00:16,219
user go back to the list of albums
without choosing a song? Well there's

4
00:00:16,219 --> 00:00:19,759
only a couple changes to be made. At the
moment, we're breaking out of the loop,

5
00:00:19,759 --> 00:00:24,230
and you can see that on line 25. Now we
don't want to do that, so what we're

6
00:00:24,230 --> 00:00:31,809
going to do is delete the break and the
else, that its in - so these two. Delete those.

7
00:00:31,809 --> 00:00:37,130
So now on line 25, we display the title
of the song. If no song's been chosen,

8
00:00:37,130 --> 00:00:42,600
we don't want to do that. In fact, my IDE,
if we hover over title,

9
00:00:42,600 --> 00:00:47,540
is giving me a warning. It says Name Title
can be not defined. If no song is selected,

10
00:00:47,540 --> 00:00:52,420
title won't have a value. So we
can fix that there, by indenting line 25,

11
00:00:52,420 --> 00:00:59,020
to make it part of the if block. So I can
come down here, indent it. Now, although it

12
00:00:59,030 --> 00:01:02,840
doesn't matter to Python, we can make
the code a bit more readable by moving

13
00:01:02,840 --> 00:01:08,660
line 25 up a line. Control shift up will
do that, on Windows, as well as Linux,

14
00:01:08,660 --> 00:01:14,340
and I think it might be command shift up, but you
can check your bindings on a Mac, if you need to.

15
00:01:14,340 --> 00:01:19,320
By doing that, it makes it pretty obvious
that line 26 isn't part of the if block,

16
00:01:19,320 --> 00:01:24,100
and that's literally all the changes we
need to make. To confirm this, though,

17
00:01:24,100 --> 00:01:29,240
let's test the program again, so
I'm going to run it. This time I'm going

18
00:01:29,240 --> 00:01:34,729
to select option 2, Bad Company. That
displays the songs on the Bad Company

19
00:01:34,729 --> 00:01:38,980
album. First thing I want to do is test
that I haven't broken anything.

20
00:01:38,980 --> 00:01:43,320
So selecting option 2, should play the
track Rock Steady. Let me do that -

21
00:01:43,320 --> 00:01:48,480
playing Rock Steady, so that's working, and
we get the albums list again, as well.

22
00:01:48,480 --> 00:01:52,500
And what I'll do, just to make sure that,
if you're watching this with subtitles,

23
00:01:52,500 --> 00:01:56,570
you can see it. I'm going to change
the View Mode to Window. We've still

24
00:01:56,570 --> 00:01:59,600
got the output, from what we've been
running in this session, so far.

25
00:01:59,600 --> 00:02:05,240
So I'm going to choose option 3, for Nightflight.
This time I'm going to make an

26
00:02:05,240 --> 00:02:10,850
invalid choice - I want to select 0, or
type in 0. As you can see, no song's

27
00:02:10,850 --> 00:02:16,320
played, and we get the albums menu again.
Now we're back to the album's menu.

28
00:02:16,320 --> 00:02:21,540
I can select 0 or another invalid choice,
and the program exits, as you can see.

29
00:02:21,540 --> 00:02:26,560
So make sure you test it more thoroughly, to make
sure it behaves well with all valid options.

30
00:02:26,560 --> 00:02:30,420
At the very least, you should
test the first and last valid choices

31
00:02:30,420 --> 00:02:34,820
in each list, and a choice from the middle
of the lists. The first and last options

32
00:02:34,820 --> 00:02:40,760
count as edge cases, and it's very
important to test edge cases. So if your

33
00:02:40,760 --> 00:02:45,720
solution behaves the same, then well done -
you've completed the challenge.

34
00:03:59,060 --> 00:04:02,100
See you in the next video.

