1
00:00:00,120 --> 00:00:02,969
Hey, you've reached the final project,

2
00:00:02,969 --> 00:00:07,740
and as you've seen at the beginning of today's lessons,

3
00:00:07,740 --> 00:00:09,600
I showed you what we're going to be making

4
00:00:09,600 --> 00:00:12,750
which is a sort of choose your own adventure game.

5
00:00:12,750 --> 00:00:14,070
I don't know if you've ever read those,

6
00:00:14,070 --> 00:00:15,570
Choose Your Own Adventure books

7
00:00:15,570 --> 00:00:17,570
where you flip to a different page

8
00:00:17,570 --> 00:00:20,190
if you make a particular choice

9
00:00:20,190 --> 00:00:24,540
and then the story kind of evolves as you make your choices.

10
00:00:24,540 --> 00:00:27,420
Now we're going to make a very simple version of that

11
00:00:27,420 --> 00:00:30,090
using what we've learned about conditionals,

12
00:00:30,090 --> 00:00:32,280
if, else, elif statements

13
00:00:32,280 --> 00:00:34,800
as well as everything we've done previously.

14
00:00:34,800 --> 00:00:37,530
So you've already seen what the final outcome

15
00:00:37,530 --> 00:00:40,320
should look like and if you want ot review it again,

16
00:00:40,320 --> 00:00:44,940
just head over to treasure-island-end.appbrewery.repl.run,

17
00:00:44,940 --> 00:00:48,780
and here you'll see essentially the game in action.

18
00:00:48,780 --> 00:00:52,350
So it starts off asking you, "You're at a crossroad,

19
00:00:52,350 --> 00:00:54,030
do you want to go left or right?"

20
00:00:54,030 --> 00:00:57,150
And then you have to type your choice.

21
00:00:57,150 --> 00:00:59,100
If you selected left,

22
00:00:59,100 --> 00:01:01,346
then it's going to take you to a lake

23
00:01:01,346 --> 00:01:04,530
and it asks you whether if you want towait for a boat

24
00:01:04,530 --> 00:01:05,760
or swim across.

25
00:01:05,760 --> 00:01:08,970
So let's go ahead and "wait for a boat".

26
00:01:08,970 --> 00:01:11,790
And then the final step is it asks you,

27
00:01:11,790 --> 00:01:13,530
which door would you like to go through

28
00:01:13,530 --> 00:01:15,720
red, yellow, or blue?

29
00:01:15,720 --> 00:01:17,310
Now depending on your choice,

30
00:01:17,310 --> 00:01:18,930
you'll either end up with game over

31
00:01:18,930 --> 00:01:22,890
or you'll end up with winning the game.

32
00:01:22,890 --> 00:01:27,030
So the basic setup for this game looks something like this.

33
00:01:27,030 --> 00:01:30,960
And I've included a link to this flowchart

34
00:01:30,960 --> 00:01:33,060
in the starting Repl.

35
00:01:33,060 --> 00:01:37,380
So replit/appbrewery/treasure-island-start,

36
00:01:37,380 --> 00:01:39,180
and of course you'll find all the links

37
00:01:39,180 --> 00:01:41,610
in the course resources as always.

38
00:01:41,610 --> 00:01:43,680
But if you scroll down, there's a link right here

39
00:01:43,680 --> 00:01:45,630
that takes you to this flowchart.

40
00:01:45,630 --> 00:01:48,660
Now, the first question you're going to ask the user

41
00:01:48,660 --> 00:01:51,190
is to make a choice between left and right.

42
00:01:51,190 --> 00:01:54,180
Now you can use my wording if you want.

43
00:01:54,180 --> 00:01:55,110
"You're at a crossroad.

44
00:01:55,110 --> 00:01:55,950
Where do you want to go?

45
00:01:55,950 --> 00:01:57,750
Type "left" or type "right"."

46
00:01:57,750 --> 00:02:00,180
But I think the fun part of this challenge

47
00:02:00,180 --> 00:02:02,534
is really creating your own story, right?

48
00:02:02,534 --> 00:02:06,420
But somehow get them to choose between left and right.

49
00:02:06,420 --> 00:02:10,350
If they choose right or any other condition for that matter,

50
00:02:10,350 --> 00:02:13,080
tell them that they've lost, Game Over

51
00:02:13,080 --> 00:02:15,090
for some sort of reason.

52
00:02:15,090 --> 00:02:17,009
In my case, if they had chosen right,

53
00:02:17,009 --> 00:02:20,460
the reason is because they fell into a hole, Game Over.

54
00:02:20,460 --> 00:02:23,100
But I think you are far more imaginative than I am.

55
00:02:23,100 --> 00:02:25,548
So go ahead and use all of those skills

56
00:02:25,548 --> 00:02:27,780
and make your game really fun.

57
00:02:27,780 --> 00:02:30,060
Now, if they've chosen left on the other hand,

58
00:02:30,060 --> 00:02:32,430
then we're going take them to another question

59
00:02:32,430 --> 00:02:33,990
that asks them whether if they want to swim

60
00:02:33,990 --> 00:02:37,560
or whether if they want to wait for a boat.

61
00:02:37,560 --> 00:02:41,550
And if they swam, then it's going to be some form of Game Over.

62
00:02:41,550 --> 00:02:44,341
There's crocodiles, there's whatever it may be,

63
00:02:44,341 --> 00:02:46,920
but they can't continue.

64
00:02:46,920 --> 00:02:49,320
But if they chose wait, then we take them to the third

65
00:02:49,320 --> 00:02:51,570
and final question which asks them to choose

66
00:02:51,570 --> 00:02:53,070
between three doors.

67
00:02:53,070 --> 00:02:54,810
And if they choose any door

68
00:02:54,810 --> 00:02:57,510
other than the yellow door, then they would lose,

69
00:02:57,510 --> 00:03:00,720
but if they chose the yellow door, then they somehow win.

70
00:03:00,720 --> 00:03:03,450
Now notice how each of these just says Game over,

71
00:03:03,450 --> 00:03:05,040
Game over, left or right,

72
00:03:05,040 --> 00:03:07,527
but you know, the idea is really to use your creativity

73
00:03:07,527 --> 00:03:10,800
and make this game really your own.

74
00:03:10,800 --> 00:03:11,970
Now one thing to remember though

75
00:03:11,970 --> 00:03:14,395
is that when the user types in an answer,

76
00:03:14,395 --> 00:03:16,770
let's say left or right,

77
00:03:16,770 --> 00:03:20,077
they might type it like this with an uppercase R

78
00:03:20,077 --> 00:03:23,220
or they might type it like this all lowercase.

79
00:03:23,220 --> 00:03:25,410
Have a think about how you might make sure

80
00:03:25,410 --> 00:03:27,360
that no matter which version they typed,

81
00:03:27,360 --> 00:03:29,620
you are still going to be able to catch

82
00:03:29,620 --> 00:03:32,190
their command essentially.

83
00:03:32,190 --> 00:03:33,023
So have a think about

84
00:03:33,023 --> 00:03:35,070
what you've learned in the previous lessons

85
00:03:35,070 --> 00:03:37,920
and take a look at this flowchart

86
00:03:37,920 --> 00:03:41,310
then head over to the Starting Project

87
00:03:41,310 --> 00:03:44,010
and you can get started writing your code.

88
00:03:44,010 --> 00:03:45,390
Now if you head over here

89
00:03:45,390 --> 00:03:48,240
and what you see is sort of like a mumbo jumbo

90
00:03:48,240 --> 00:03:49,770
bunch of characters,

91
00:03:49,770 --> 00:03:52,920
then the reason is probably because there's not enough space

92
00:03:52,920 --> 00:03:57,000
for this ASCII art of a Treasure Chest to display.

93
00:03:57,000 --> 00:03:58,860
So you can either do, as I did,

94
00:03:58,860 --> 00:04:01,567
reduce the size of the console

95
00:04:01,567 --> 00:04:04,260
or alternatively and probably easier

96
00:04:04,260 --> 00:04:06,360
is to change the layout to stacked,

97
00:04:06,360 --> 00:04:09,412
make it go at the bottom, collapse this left hand pane,

98
00:04:09,412 --> 00:04:14,013
and then you've got as much space as you have to work with.

99
00:04:15,240 --> 00:04:16,950
Now ASCII art is really cool,

100
00:04:16,950 --> 00:04:18,870
because it basically just uses

101
00:04:18,870 --> 00:04:20,910
a bunch of characters that you know and love

102
00:04:20,910 --> 00:04:23,220
like the comma and the equal sign

103
00:04:23,220 --> 00:04:27,663
and all of these things that together make up a picture.

104
00:04:28,590 --> 00:04:30,285
And you can find your own ASCII art

105
00:04:30,285 --> 00:04:34,500
if you just go to ascii.co.uk/art

106
00:04:34,500 --> 00:04:36,910
and you'll see a whole bunch of different topics

107
00:04:36,910 --> 00:04:40,188
and they've grouped a lot of things together

108
00:04:40,188 --> 00:04:42,270
into individual pages.

109
00:04:42,270 --> 00:04:44,610
So if you wanted a rhino ASCII art,

110
00:04:44,610 --> 00:04:47,220
then you can find a whole bunch of rhinos

111
00:04:47,220 --> 00:04:49,110
that people have drawn.

112
00:04:49,110 --> 00:04:51,780
But the easiest way is of course using Command + F

113
00:04:51,780 --> 00:04:52,613
if you're on a Mac

114
00:04:52,613 --> 00:04:55,350
or Ctrl + F if you're on a Windows machine,

115
00:04:55,350 --> 00:04:57,450
and then just search for the thing that you want.

116
00:04:57,450 --> 00:05:00,750
So for example, I went and searched for treasure,

117
00:05:00,750 --> 00:05:04,470
and down here I found this brilliant Treasure Box

118
00:05:04,470 --> 00:05:06,930
in ASCII art, which is what I'm using

119
00:05:06,930 --> 00:05:10,350
to print inside this print statement.

120
00:05:10,350 --> 00:05:13,121
Now, notice how there's three single quotes (' ' ')

121
00:05:13,121 --> 00:05:14,562
that are at the start

122
00:05:14,562 --> 00:05:17,580
and there's three single quotes (' ' ') at the end.

123
00:05:17,580 --> 00:05:20,040
Basically what the single quotes allow you to do

124
00:05:20,040 --> 00:05:24,540
is to create multiple lines of a string essentially.

125
00:05:24,540 --> 00:05:26,760
So notice how if I go ahead and delete

126
00:05:26,760 --> 00:05:29,280
all of these single quotes

127
00:05:29,280 --> 00:05:33,090
and I only had a set of double quotes,

128
00:05:33,090 --> 00:05:36,003
then it actually doesn't quite work.

129
00:05:37,350 --> 00:05:40,500
It gets quite confused because it thinks

130
00:05:40,500 --> 00:05:43,260
that this is where the line ends,

131
00:05:43,260 --> 00:05:46,260
but in fact, I wanted to print all of this out.

132
00:05:46,260 --> 00:05:49,140
So to do that, instead of using a double quote,

133
00:05:49,140 --> 00:05:51,570
I use three single quotes.

134
00:05:51,570 --> 00:05:53,040
And at the very bottom,

135
00:05:53,040 --> 00:05:56,640
I tell it well this is the end of my multi block string

136
00:05:56,640 --> 00:05:59,280
by using three single quotes as well.

137
00:05:59,280 --> 00:06:00,630
So have a go at running that

138
00:06:00,630 --> 00:06:03,240
and you should be able to see that in your console.

139
00:06:03,240 --> 00:06:06,780
You get this little Treasure Island ASCII art being printed

140
00:06:06,780 --> 00:06:10,170
along with the two sentences that begin the game.

141
00:06:10,170 --> 00:06:12,277
S  have a look at the flow chart,

142
00:06:12,277 --> 00:06:15,120
have a play around with the ASCII art,

143
00:06:15,120 --> 00:06:19,170
and also have a look at the final version of the app

144
00:06:19,170 --> 00:06:20,580
so that you can go ahead

145
00:06:20,580 --> 00:06:24,630
and create your own version to complete this challenge.

146
00:06:24,630 --> 00:06:26,580
Pause the video now and give that a go.

147
00:06:30,750 --> 00:06:31,583
All right, so let's see

148
00:06:31,583 --> 00:06:34,290
if we can replicate the functionality

149
00:06:34,290 --> 00:06:37,110
or the logic that's shown in this diagram

150
00:06:37,110 --> 00:06:39,120
into our Treasure Island game.

151
00:06:39,120 --> 00:06:42,750
So the first thing it has to do is we have to ask the user

152
00:06:42,750 --> 00:06:45,090
whether if they want to turn left or right.

153
00:06:45,090 --> 00:06:47,338
And after we ask the user this question,

154
00:06:47,338 --> 00:06:51,540
we're going to want to capture their input, right?

155
00:06:51,540 --> 00:06:52,410
So let's go ahead

156
00:06:52,410 --> 00:06:56,823
and create an input() function and ask our question.

157
00:07:00,570 --> 00:07:05,520
Now notice how when I use my double quotes around my string,

158
00:07:05,520 --> 00:07:08,370
the double quotes that are inside the double quotes

159
00:07:08,370 --> 00:07:12,210
are interpreted as code because it actually thinks that

160
00:07:12,210 --> 00:07:15,180
this is the end of the first string,

161
00:07:15,180 --> 00:07:18,090
this is the second string, and this is the final string.

162
00:07:18,090 --> 00:07:20,550
This is how the computer is going see it.

163
00:07:20,550 --> 00:07:22,980
Now previously you saw that we could do the trick

164
00:07:22,980 --> 00:07:27,090
where we change this to single quotes instead.

165
00:07:27,090 --> 00:07:29,728
But if like me, you have this case

166
00:07:29,728 --> 00:07:34,350
where you have the "You're" with the apostrophe,

167
00:07:34,350 --> 00:07:35,910
then it's going to think

168
00:07:35,910 --> 00:07:38,430
that this is actually the end of the first string

169
00:07:38,430 --> 00:07:41,220
this is the second string and this is the third string.

170
00:07:41,220 --> 00:07:43,800
So this doesn't actually really help us.

171
00:07:43,800 --> 00:07:47,400
Now all we can do when we want to tell our computer

172
00:07:47,400 --> 00:07:49,890
that what I'm writing is actually not code

173
00:07:49,890 --> 00:07:52,350
just see it as text.

174
00:07:52,350 --> 00:07:55,590
You can get it to ignore a symbol afterwards

175
00:07:55,590 --> 00:07:57,930
by using the backslash (\).

176
00:07:57,930 --> 00:08:01,860
So this way it basically escapes this string

177
00:08:01,860 --> 00:08:04,290
and it will see it as text.

178
00:08:04,290 --> 00:08:07,938
And now we have a complete string like this

179
00:08:07,938 --> 00:08:10,950
and this is just going to be interpreted as text

180
00:08:10,950 --> 00:08:13,710
because we told it to with the backslash.

181
00:08:13,710 --> 00:08:15,060
Now of course there's other ways

182
00:08:15,060 --> 00:08:16,320
that you could have gone around this.

183
00:08:16,320 --> 00:08:18,120
You could have just simply said

184
00:08:18,120 --> 00:08:22,710
"You are at a crossroad..." rather than using the apostrophe,

185
00:08:22,710 --> 00:08:23,760
but more often than not,

186
00:08:23,760 --> 00:08:26,340
you'll need to use a symbol that you'll need to escape

187
00:08:26,340 --> 00:08:27,960
and you can do that with the backslash.

188
00:08:27,960 --> 00:08:29,850
So that's just a quick tip.

189
00:08:29,850 --> 00:08:30,750
Now at this point,

190
00:08:30,750 --> 00:08:34,799
the user is going to type a message left or right.

191
00:08:34,799 --> 00:08:37,631
So let's go ahead and save that to a variable.

192
00:08:37,631 --> 00:08:40,740
Let's call it choice1 equals their input.

193
00:08:40,740 --> 00:08:43,380
Now remember how I said they could be typing the answer

194
00:08:43,380 --> 00:08:45,660
as "Right" or as "right".

195
00:08:45,660 --> 00:08:49,290
So how can we make sure that when we are doing our checks

196
00:08:49,290 --> 00:08:52,920
using the if statement we ignore the casing?

197
00:08:52,920 --> 00:08:55,012
Well, one way of doing this is we can simply

198
00:08:55,012 --> 00:08:59,070
use the "lower() function" to change their input

199
00:08:59,070 --> 00:09:02,520
no matter how they wrote it, Right, right, or RIGHT,

200
00:09:02,520 --> 00:09:07,350
it should all be converted into lowercase to this version.

201
00:09:07,350 --> 00:09:08,585
That way we have one thing

202
00:09:08,585 --> 00:09:12,180
that we can consistently check for in our if statement,

203
00:09:12,180 --> 00:09:13,500
which is coming up next.

204
00:09:13,500 --> 00:09:17,756
So we can say if choice1 ==, remember

205
00:09:17,756 --> 00:09:20,294
the double equals is checking

206
00:09:20,294 --> 00:09:23,220
whether if left hand side and right hand side is equal

207
00:09:23,220 --> 00:09:27,210
and the single equal sign is assigning the right hand side

208
00:09:27,210 --> 00:09:29,790
to this particular variable name.

209
00:09:29,790 --> 00:09:33,300
Now if choice1 equals the string right,

210
00:09:33,300 --> 00:09:36,390
then it's pretty much Game Over for our player.

211
00:09:36,390 --> 00:09:39,210
So let's go ahead and add our colon

212
00:09:39,210 --> 00:09:43,860
and print something like Game Over.

213
00:09:43,860 --> 00:09:45,960
Of course we can elaborate this a little bit more

214
00:09:45,960 --> 00:09:47,790
as to why was it Game Over.

215
00:09:47,790 --> 00:09:52,020
"Well, because you fell into a hole."

216
00:09:52,020 --> 00:09:54,933
This is like the ET game from the '80s.

217
00:09:55,830 --> 00:09:57,037
Lots of holes.

218
00:09:57,037 --> 00:10:00,813
So, "You fell into a hole. Game Over."

219
00:10:00,813 --> 00:10:05,550
But what if they had chosen left instead?

220
00:10:05,550 --> 00:10:08,130
Well, that takes them on to the next question.

221
00:10:08,130 --> 00:10:11,250
So that's the option that will allow them to continue

222
00:10:11,250 --> 00:10:12,213
along the game.

223
00:10:13,410 --> 00:10:17,100
Now in this case, we could use an else statement and say,

224
00:10:17,100 --> 00:10:18,750
well if they didn't choose right,

225
00:10:18,750 --> 00:10:21,330
then they probably chose left, right?

226
00:10:21,330 --> 00:10:23,910
But they could have also chosen like an option

227
00:10:23,910 --> 00:10:25,560
that was completely not listed.

228
00:10:25,560 --> 00:10:28,320
They could have just written something like this

229
00:10:28,320 --> 00:10:31,410
and it would still trigger the else statement.

230
00:10:31,410 --> 00:10:36,240
So what we should actually do is to switch it around.

231
00:10:36,240 --> 00:10:41,240
So namely we should say, if choice1 == "left":

232
00:10:43,140 --> 00:10:48,140
well in that case, then they continue you in the game.

233
00:10:48,870 --> 00:10:52,980
But otherwise, namely if they chose "right" 

234
00:10:52,980 --> 00:10:55,140
or anything else for that matter,

235
00:10:55,140 --> 00:10:57,360
then it's pretty much Game Over.

236
00:10:57,360 --> 00:10:59,520
So this format makes a lot more sense

237
00:10:59,520 --> 00:11:01,110
if you want to continue

238
00:11:01,110 --> 00:11:04,800
along the left side of the branch, this way.

239
00:11:04,800 --> 00:11:07,290
Now another thing that you might have realized

240
00:11:07,290 --> 00:11:10,860
because we learned about combining different conditions

241
00:11:10,860 --> 00:11:13,980
is instead of using the .lower()

242
00:11:13,980 --> 00:11:16,650
to change the input to lowercase,

243
00:11:16,650 --> 00:11:20,310
you could have also said if choice == "left"

244
00:11:20,310 --> 00:11:25,310
or if choice1 == "Left": spelt like this,

245
00:11:25,500 --> 00:11:26,996
that will both work.

246
00:11:26,996 --> 00:11:31,526
But I think in terms of succinctness and less code writing,

247
00:11:31,526 --> 00:11:35,250
I think this makes a lot more sense to me.

248
00:11:35,250 --> 00:11:37,440
So I'm going to continue with this version.

249
00:11:37,440 --> 00:11:38,940
But if you did it the other way,

250
00:11:38,940 --> 00:11:40,923
that's perfectly valid as well.

251
00:11:41,820 --> 00:11:44,400
Now if their choice1 was left,

252
00:11:44,400 --> 00:11:46,560
then they get taken to the next question.

253
00:11:46,560 --> 00:11:48,510
Do you want to swim or do you want to wait?

254
00:11:49,410 --> 00:11:51,450
So let's go ahead and continue the game

255
00:11:51,450 --> 00:11:55,230
and create another input.

256
00:11:55,230 --> 00:11:58,260
In this input we're going to ask them a question

257
00:11:58,260 --> 00:12:01,830
and say, "You've come to a lake.

258
00:12:01,830 --> 00:12:06,330
There is an island in the middle of the lake.

259
00:12:06,330 --> 00:12:11,100
Type "wait" to wait for a boat.

260
00:12:11,100 --> 00:12:15,990
Type "swim" to swim across.

261
00:12:15,990 --> 00:12:18,630
Cool, so we've actually got the same problem

262
00:12:18,630 --> 00:12:23,610
as we had before, namely that this is being interpreted

263
00:12:23,610 --> 00:12:28,380
as code rather than as a continuous single string.

264
00:12:28,380 --> 00:12:31,080
So do you remember how we fixed this previously?

265
00:12:31,080 --> 00:12:32,940
And if you got stuck on this,

266
00:12:32,940 --> 00:12:34,920
I recommend having a go at this yourself

267
00:12:34,920 --> 00:12:36,423
before I show you the answer.

268
00:12:37,913 --> 00:12:40,650
All right, so previously we said we were going to switch it

269
00:12:40,650 --> 00:12:42,690
to single quotes instead

270
00:12:42,690 --> 00:12:46,110
so that these double quotes become interpreted

271
00:12:46,110 --> 00:12:48,420
as just normal strings.

272
00:12:48,420 --> 00:12:50,940
But of course we've got this "You've,"

273
00:12:50,940 --> 00:12:54,870
we could of course change it to "you have" instead of you've,

274
00:12:54,870 --> 00:12:58,500
but if we want to escape the string, we just add a \

275
00:12:58,500 --> 00:13:01,590
and now everything is colored in this sort of pinkish color

276
00:13:01,590 --> 00:13:04,980
to indicate it's all interpreted as a string,

277
00:13:04,980 --> 00:13:07,053
which is exactly what we did previously.

278
00:13:07,950 --> 00:13:09,540
Now in terms of this input,

279
00:13:09,540 --> 00:13:12,390
they're going to type "wait" or they're going to type "swim".

280
00:13:12,390 --> 00:13:15,810
So let's go ahead and lower the casing for it as well,

281
00:13:15,810 --> 00:13:18,990
and then we're going to save it inside a choice.

282
00:13:18,990 --> 00:13:21,000
We're going to say choice2.

283
00:13:21,000 --> 00:13:25,470
Now be really careful and mindful of your indentation,

284
00:13:25,470 --> 00:13:28,020
because if you wrote it like this,

285
00:13:28,020 --> 00:13:31,170
then it's going to be creating some errors for you

286
00:13:31,170 --> 00:13:34,530
because this choice2 input line

287
00:13:34,530 --> 00:13:38,043
has to run when this choice1 is equal to left,

288
00:13:39,030 --> 00:13:42,120
otherwise we're going to get an indentation error.

289
00:13:42,120 --> 00:13:44,790
So let's go ahead and indent it here

290
00:13:44,790 --> 00:13:48,810
to show that this part is inside this if statement

291
00:13:48,810 --> 00:13:52,770
and will only be executed if this is true.

292
00:13:52,770 --> 00:13:55,800
And then we get to check our choice2.

293
00:13:55,800 --> 00:13:59,640
So, if choice2 == "wait": ,

294
00:14:01,020 --> 00:14:03,993
then it means that the game will continue,

295
00:14:06,210 --> 00:14:09,930
but else, so if they typed swim

296
00:14:09,930 --> 00:14:12,180
or anything else for that matter,

297
00:14:12,180 --> 00:14:13,800
then the game is going to end.

298
00:14:13,800 --> 00:14:15,030
So we're going to print

299
00:14:15,030 --> 00:14:17,370
and tell them that something terrible happened,

300
00:14:17,370 --> 00:14:22,173
"You got attacked by an angry trout.

301
00:14:24,420 --> 00:14:25,253
Game Over."

302
00:14:26,220 --> 00:14:28,272
Now we can continue along this path.

303
00:14:28,272 --> 00:14:30,045
So we're down to here now.

304
00:14:30,045 --> 00:14:32,850
And the final question we're going to ask the user

305
00:14:32,850 --> 00:14:36,150
is which door do they want to choose?

306
00:14:36,150 --> 00:14:38,376
So here I'm going to use an input()

307
00:14:38,376 --> 00:14:40,830
to send them the message

308
00:14:40,830 --> 00:14:43,260
that, "You arrive at the island unharmed.

309
00:14:43,260 --> 00:14:44,610
There is a house with three doors.

310
00:14:44,610 --> 00:14:46,500
One red, one yellow, one blue.

311
00:14:46,500 --> 00:14:48,750
Which color do you choose?"

312
00:14:48,750 --> 00:14:51,450
Now I'm going to save their choice

313
00:14:51,450 --> 00:14:54,420
inside a variable called choice3,

314
00:14:54,420 --> 00:14:58,560
lowercase the answer that they provided.

315
00:14:58,560 --> 00:15:01,740
And finally I'm going to use if, elif, and else

316
00:15:01,740 --> 00:15:03,930
to check which one they chose.

317
00:15:03,930 --> 00:15:08,930
So if choice3 == "red":

318
00:15:10,380 --> 00:15:15,003
elif choice3 == yellow,

319
00:15:18,060 --> 00:15:22,263
elif choice3 is equal to blue.

320
00:15:23,310 --> 00:15:25,680
And then I've got an else.

321
00:15:25,680 --> 00:15:28,500
So here are four possible things that could happen.

322
00:15:28,500 --> 00:15:31,770
If they chose red, then I'm going tell them

323
00:15:31,770 --> 00:15:33,900
that it's Game Over,

324
00:15:33,900 --> 00:15:36,240
but it's going to be some sort of creative

325
00:15:36,240 --> 00:15:37,620
version of Game Over.

326
00:15:37,620 --> 00:15:41,460
So maybe something like, "It's a room full of fire.

327
00:15:41,460 --> 00:15:42,840
Game Over."

328
00:15:42,840 --> 00:15:46,500
If they chose yellow on the other hand,

329
00:15:46,500 --> 00:15:49,170
well that's going to be the room where the treasure exists.

330
00:15:49,170 --> 00:15:51,750
So I'm going to print, "You found the treasure!

331
00:15:51,750 --> 00:15:52,890
You Win!"

332
00:15:52,890 --> 00:15:57,450
If they chose blue, they also end up with Game Over

333
00:15:57,450 --> 00:16:00,273
and I have to give them a different reason.

334
00:16:01,110 --> 00:16:02,550
Now if you had decided

335
00:16:02,550 --> 00:16:05,820
that if they chose anything but yellow,

336
00:16:05,820 --> 00:16:09,390
the way that they're going to game over is the same,

337
00:16:09,390 --> 00:16:11,760
say if, you know, if you chose red,

338
00:16:11,760 --> 00:16:12,840
"It's a room full of fire.

339
00:16:12,840 --> 00:16:13,673
Game Over."

340
00:16:13,673 --> 00:16:15,450
If you chose blue, "It's a room full of fire.

341
00:16:15,450 --> 00:16:16,590
Game Over."

342
00:16:16,590 --> 00:16:18,623
Anything else, it's also going to be fire.

343
00:16:18,623 --> 00:16:20,100
Game over.

344
00:16:20,100 --> 00:16:22,800
Well then you could just use if and else,

345
00:16:22,800 --> 00:16:25,770
but if you wanted each choice or each door

346
00:16:25,770 --> 00:16:27,690
to have a different outcome for the user,

347
00:16:27,690 --> 00:16:31,200
say, "The red door has fire. The blue door has beasts."

348
00:16:31,200 --> 00:16:33,420
And if they chose the wrong door,

349
00:16:33,420 --> 00:16:35,420
then they're going to get something like

350
00:16:36,720 --> 00:16:38,370
"You chose a door that doesn't exist.

351
00:16:38,370 --> 00:16:39,510
Game Over." 

352
00:16:39,510 --> 00:16:40,620
So can you see that

353
00:16:40,620 --> 00:16:43,329
depending on whether if you want to give the user

354
00:16:43,329 --> 00:16:48,329
a different print statement based on their choice,

355
00:16:48,900 --> 00:16:51,600
then you would use if, elif, else,

356
00:16:51,600 --> 00:16:52,530
but if you actually

357
00:16:52,530 --> 00:16:54,960
just wanted to give them the same feedback,

358
00:16:54,960 --> 00:16:59,208
which is Game Over, then you could just use if and else.

359
00:16:59,208 --> 00:17:03,330
Now let's run our game and just make sure that it works.

360
00:17:03,330 --> 00:17:06,869
So I'm going to go left because I know it continues,

361
00:17:06,869 --> 00:17:10,260
and then I'm going to wait for the boat,

362
00:17:10,260 --> 00:17:13,230
and that allows me to get to the final condition.

363
00:17:13,230 --> 00:17:16,109
And if I choose yellow, I know that I'll win.

364
00:17:16,109 --> 00:17:18,150
Now if you want to change the formatting,

365
00:17:18,150 --> 00:17:21,510
because having the input at the end of the sentence

366
00:17:21,510 --> 00:17:24,060
doesn't look as good as letting the user type it

367
00:17:24,060 --> 00:17:27,480
on a new line like what we've got here,

368
00:17:27,480 --> 00:17:31,860
then you can simply, if you remember, just add the new line

369
00:17:31,860 --> 00:17:36,393
which is \n at the end of your inputs, like so.

370
00:17:38,490 --> 00:17:41,340
So how did you get on with this challenge?

371
00:17:41,340 --> 00:17:43,140
And if you didn't manage to do it right

372
00:17:43,140 --> 00:17:46,980
or if you've done it right, go back and try and modify it.

373
00:17:46,980 --> 00:17:49,530
See if you can add some more conditions

374
00:17:49,530 --> 00:17:52,427
or see if you can make the Game Over messages

375
00:17:52,427 --> 00:17:55,200
a little bit more interesting than what I've written.

376
00:17:55,200 --> 00:17:58,830
See if you can modify and make it really your own.

377
00:17:58,830 --> 00:17:59,910
Have fun with that.

378
00:17:59,910 --> 00:18:01,440
And in the next lesson,

379
00:18:01,440 --> 00:18:03,900
I've got more exciting things coming up for you.

380
00:18:03,900 --> 00:18:06,840
So hopefully you've scheduled some time for tomorrow

381
00:18:06,840 --> 00:18:09,630
to complete the next day's lessons.

382
00:18:09,630 --> 00:18:11,643
But for now, it's goodnight for me.

