All language subtitles for 036 Day 3 Project_ Treasure Island.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,070 --> 00:00:00,550 Hey, 2 00:00:00,550 --> 00:00:05,550 you've reached the final project and as you've seen at the beginning of today's 3 00:00:06,640 --> 00:00:09,580 lessons, I showed you what we're going to be making, 4 00:00:09,580 --> 00:00:12,520 which is a sort of choose your own adventure game. 5 00:00:12,700 --> 00:00:14,020 I don't know if you've ever read those 6 00:00:14,020 --> 00:00:18,880 choose your own adventure books where you flip to a different page if you 7 00:00:18,880 --> 00:00:23,380 make a particular choice and then the story kind of evolves as you make your 8 00:00:23,380 --> 00:00:24,213 choices. 9 00:00:24,520 --> 00:00:28,780 Now we're going to make a very simple version of that using what we've learned 10 00:00:28,810 --> 00:00:33,760 about conditionals: if, else, elif statements as well as everything we've done 11 00:00:33,760 --> 00:00:38,410 previously. So you've already seen what the final outcome should look like. 12 00:00:38,500 --> 00:00:40,030 And if you want to review it again, 13 00:00:40,270 --> 00:00:44,560 just head over to treasure-island-end.app brewery.repl.run. 14 00:00:44,950 --> 00:00:48,250 And here you'll see essentially the game in action. 15 00:00:48,730 --> 00:00:53,680 So it start off asking you, you're at a crossroad. Do you want to go left or right? 16 00:00:54,040 --> 00:00:59,020 And then you have to type your choice. If you selected left, 17 00:00:59,080 --> 00:01:03,490 then it's going to take you to a Lake and it asks you whether if you want to 18 00:01:03,490 --> 00:01:08,410 wait for a boat or swim across. So let's go ahead and wait for a boat. 19 00:01:08,980 --> 00:01:13,480 And then the final step is it asks you which door would you like to go through? 20 00:01:13,510 --> 00:01:17,260 Red, yellow, or blue. Now depending on your choice, 21 00:01:17,290 --> 00:01:21,580 you'll either end up with game over or you'll end up with, um, 22 00:01:21,610 --> 00:01:22,443 winning the game. 23 00:01:22,870 --> 00:01:26,920 So the basic setup for this game looks something like this. 24 00:01:27,040 --> 00:01:32,040 And I've included a link to this flow chart in the starting repl. 25 00:01:33,040 --> 00:01:37,030 So repl.it/@appbrewery/treasure-island-start 26 00:01:37,390 --> 00:01:41,290 and of course you'll find all the links in the course resources as always. 27 00:01:41,590 --> 00:01:42,610 But if you scroll down, 28 00:01:42,670 --> 00:01:44,980 there's a link right here that takes you to this flow chart. 29 00:01:45,610 --> 00:01:50,230 Now the first question you're going to ask the user is to make a choice between 30 00:01:50,230 --> 00:01:55,120 left and right. Now you can use my wording. Um, if you want your at a crossroad, 31 00:01:55,120 --> 00:01:57,310 where do you want to go? Type left or type right? 32 00:01:57,700 --> 00:02:02,140 But I think the fun part of this challenge is really creating your own story, 33 00:02:02,290 --> 00:02:02,830 right? 34 00:02:02,830 --> 00:02:07,830 But somehow get them to choose between left and right. If they choose right or 35 00:02:08,050 --> 00:02:09,820 any other condition for that matter, 36 00:02:10,330 --> 00:02:14,380 tell them that they've lost game over for some sort of reason. 37 00:02:15,040 --> 00:02:17,230 In my case, if they had chosen, right, 38 00:02:17,290 --> 00:02:20,020 the reason is because they fell into a hole. Game over. 39 00:02:20,410 --> 00:02:23,080 But I think you're far more imaginative than I am. 40 00:02:23,080 --> 00:02:27,250 So go ahead and use all of those skills and make your game really fun. 41 00:02:27,730 --> 00:02:29,980 Now if they've chosen left on the other hand, 42 00:02:30,040 --> 00:02:33,370 then we're going to take them to another question that asks them whether if they 43 00:02:33,370 --> 00:02:37,420 want to swim or whether if they want to wait for a boat. Um, 44 00:02:37,540 --> 00:02:41,530 and if they swam, then it's going to be some form of game over. 45 00:02:41,530 --> 00:02:46,390 There's crocodiles, there's, um, whatever it may be, but they can't continue. 46 00:02:46,870 --> 00:02:50,350 But if they chose wait, then we take them to the third and final question, 47 00:02:50,380 --> 00:02:52,570 which asks them to choose between three doors. 48 00:02:53,050 --> 00:02:57,490 And if they choose any door other than the yellow door, then they would lose. 49 00:02:57,520 --> 00:03:00,160 But if they chose the yellow door, then they somehow win. 50 00:03:00,700 --> 00:03:04,750 Now notice how each of these just says, game over, game over, left or right, 51 00:03:04,990 --> 00:03:05,620 but you know, 52 00:03:05,620 --> 00:03:10,030 the idea is really to use your creativity and make this game really your own. 53 00:03:10,780 --> 00:03:14,800 Now one thing to remember though is that when the user types in a answer, 54 00:03:14,800 --> 00:03:18,640 let's say left or right, they might type it like this, um, 55 00:03:18,670 --> 00:03:22,780 with an upper case R or they might type it like this, all lower case. 56 00:03:23,200 --> 00:03:26,710 Have a think about how you might make sure that no matter which version they 57 00:03:26,710 --> 00:03:31,690 typed, you're still going to be able to catch their command essentially. 58 00:03:32,170 --> 00:03:35,770 So have a think about what you've learned in the previous lessons and take a 59 00:03:35,770 --> 00:03:37,660 look at this flow chart, 60 00:03:37,900 --> 00:03:42,900 then head over to the starting project and you can get started writing your 61 00:03:43,120 --> 00:03:47,830 code. Now if you head over here and what you see is sort of like a mumbo jumbo 62 00:03:47,830 --> 00:03:49,540 a bunch of characters, 63 00:03:49,750 --> 00:03:54,730 then the reason is probably because there's not enough space for this ASCII art 64 00:03:54,970 --> 00:03:58,510 of a treasure chest to display. So you can either do as I did, 65 00:03:58,840 --> 00:04:03,840 reduce the size of the console or alternatively and probably easier is to change 66 00:04:04,840 --> 00:04:08,320 the layout to stacked, make it go with the bottom, collapse 67 00:04:08,320 --> 00:04:09,610 this left hand pane 68 00:04:09,730 --> 00:04:13,870 and then you've got as much space as you have to work with. 69 00:04:15,190 --> 00:04:20,050 Now ASCII art is really cool because it basically just uses a bunch of characters 70 00:04:20,050 --> 00:04:20,883 that you know and love, 71 00:04:20,890 --> 00:04:25,750 like the comma and the equal sign and all of these things that, um, 72 00:04:25,780 --> 00:04:30,780 together make up a picture. And you can find your own ASCII art if you just go to 73 00:04:31,630 --> 00:04:32,620 ascii.co. 74 00:04:32,620 --> 00:04:37,300 uk/art and you'll see a whole bunch of different topics. 75 00:04:37,360 --> 00:04:42,220 Um, and they've grouped a lot of things together into individual pages. 76 00:04:42,250 --> 00:04:44,300 So if you wanted to a rhino ASCII art, 77 00:04:44,570 --> 00:04:48,490 then you can find a whole bunch of rhinos that people have drawn. 78 00:04:49,060 --> 00:04:53,050 But the easiest way is, of course, using a command F if you're on a Mac or control 79 00:04:53,050 --> 00:04:57,160 F if you're on a Windows machine and then just search for the thing that you 80 00:04:57,160 --> 00:05:00,190 want. So, for example, I went and searched for treasure, 81 00:05:00,730 --> 00:05:05,140 and down here I found this brilliant treasure box, ASCII art, 82 00:05:05,530 --> 00:05:09,700 which is what I'm using to print inside this print statement. 83 00:05:10,300 --> 00:05:15,300 Now notice how there's three single quotes that are at the start and there's 84 00:05:15,460 --> 00:05:17,140 three single quotes at the end. 85 00:05:17,560 --> 00:05:22,150 Basically what the single quotes allow you to do is to create multiple lines of, 86 00:05:22,180 --> 00:05:23,980 um, a string essentially. 87 00:05:24,520 --> 00:05:27,670 So notice how if I go ahead and delete all of these, uh, 88 00:05:27,700 --> 00:05:32,260 single quotes and I only had a set of double quotes, 89 00:05:33,070 --> 00:05:35,860 then it actually doesn't quite work. 90 00:05:37,330 --> 00:05:39,550 It gets quite confused, um, 91 00:05:39,580 --> 00:05:43,900 because it thinks that this is where the line ends. But in fact, 92 00:05:43,900 --> 00:05:47,140 I want it to print all of this out. So to do that, 93 00:05:47,170 --> 00:05:51,280 instead of using a double quote, I use three single quotes. 94 00:05:51,520 --> 00:05:53,590 And at the very bottom I tell it, well, 95 00:05:53,590 --> 00:05:58,590 this is the end of my multi block string by using three single quotes as well. 96 00:05:59,240 --> 00:06:02,270 So I have a go at running that and you should be able to see that in your 97 00:06:02,270 --> 00:06:03,103 console 98 00:06:03,230 --> 00:06:07,730 you get this little treasure Island ASCII art being printed along with the two 99 00:06:07,730 --> 00:06:12,620 sentences that begin the game. So have a look at the flowcharts, um, 100 00:06:12,650 --> 00:06:17,600 have a play around with the ASCII arts and also have a look at the final 101 00:06:17,600 --> 00:06:22,600 version of the app so that you can go ahead and create your own version to 102 00:06:22,820 --> 00:06:26,210 complete this challenge. Pause the video now and give that a go. 103 00:06:30,220 --> 00:06:30,730 Yeah. 104 00:06:30,730 --> 00:06:31,060 All right, 105 00:06:31,060 --> 00:06:35,770 so let's see if we can replicate the functionality or the logic that's shown in 106 00:06:35,770 --> 00:06:38,770 this diagram into a treasure Island game. 107 00:06:39,100 --> 00:06:43,360 So the first thing it has to do is we have to ask the user whether if they want 108 00:06:43,360 --> 00:06:48,040 to turn left or right, and after we ask the user this question, 109 00:06:48,400 --> 00:06:51,340 we're going to want to capture their input, right? 110 00:06:51,550 --> 00:06:56,550 So let's go ahead and create an input function and ask our question. 111 00:07:00,070 --> 00:07:00,580 Yeah. 112 00:07:00,580 --> 00:07:05,020 Now notice how when I use my double quotes around my string, 113 00:07:05,470 --> 00:07:10,120 the double quotes that are inside the double quotes are interpreted as code 114 00:07:10,120 --> 00:07:14,470 because it actually thinks that this is the end of the first string, 115 00:07:15,100 --> 00:07:18,010 this is the second string, and this is the final string. 116 00:07:18,040 --> 00:07:20,770 This is how the computer is going to see it. Now, 117 00:07:20,800 --> 00:07:25,390 previously you saw that we could do the trick where we change this to single 118 00:07:25,390 --> 00:07:29,200 quotes instead, but if like me, 119 00:07:29,200 --> 00:07:33,640 you have this case where you have the your with the apostrophe, 120 00:07:34,300 --> 00:07:38,020 then it's going to think that this is actually the end of the first string, 121 00:07:38,410 --> 00:07:41,200 this is the second string and this is the third string. 122 00:07:41,200 --> 00:07:43,210 So this doesn't actually really help us. 123 00:07:43,780 --> 00:07:48,780 Now what we can do when we want to tell our computer that what I'm writing is 124 00:07:48,820 --> 00:07:51,910 actually not code, just see it as text. 125 00:07:52,300 --> 00:07:57,300 You can get it to ignore a symbol afterwards by using the backslash. 126 00:07:57,910 --> 00:08:02,910 So this way it basically escapes the string and it will see it as text and now 127 00:08:05,080 --> 00:08:07,840 we have a complete string like this, 128 00:08:08,170 --> 00:08:12,460 and this is just going to be interpreted as text because we told it to with the 129 00:08:12,460 --> 00:08:14,230 backslash. Now of course, 130 00:08:14,230 --> 00:08:16,270 there's other ways that you could have gone around this. 131 00:08:16,270 --> 00:08:21,270 You could have just simply said you are at at a crossroad rather than using the 132 00:08:21,400 --> 00:08:23,710 apostrophe. But more often than not, 133 00:08:23,710 --> 00:08:27,160 you'll need to use a symbol that you'll need to escape and you can do that with 134 00:08:27,160 --> 00:08:30,730 the backslash. So that's just a quick tip. Now at this point, 135 00:08:30,730 --> 00:08:34,210 the user is going to type a message left or right. 136 00:08:34,750 --> 00:08:37,510 So let's go ahead and save that to a variable. 137 00:08:37,540 --> 00:08:40,120 Let's call it choice1 equals their input. 138 00:08:40,720 --> 00:08:45,580 Now, remember how I said they could be typing the answer as Right or as right. 139 00:08:45,640 --> 00:08:50,350 So how can we make sure that when we're doing our checks using if statement, 140 00:08:50,950 --> 00:08:52,240 we ignore the casing? 141 00:08:52,870 --> 00:08:57,870 Well one way of doing this is we can use the lower function to change their input 142 00:08:59,040 --> 00:09:02,160 no matter how they wrote it, Right, right or RIGHT, 143 00:09:02,520 --> 00:09:06,810 it should all be converted into lowercase, to this version. 144 00:09:07,320 --> 00:09:11,580 That way we have one thing that we can consistently check for in our if 145 00:09:11,580 --> 00:09:13,200 statement, which is coming up next. 146 00:09:13,440 --> 00:09:18,440 So we can say if choice1 is equal to, remember the double equals is checking 147 00:09:20,610 --> 00:09:22,920 whether a left hand side and righthand side is equal 148 00:09:23,190 --> 00:09:28,190 and a single equal sign is assigning the right-hand side to this particular 149 00:09:28,230 --> 00:09:32,880 variable name. Now if choice1 equals the string, right, 150 00:09:33,300 --> 00:09:36,090 then it's pretty much game over for our player. 151 00:09:36,390 --> 00:09:41,390 So let's go ahead and add our colon and print something like Game over. 152 00:09:43,860 --> 00:09:47,790 Of course, we can elaborate this a little bit more as to why it was a game over. 153 00:09:47,790 --> 00:09:51,480 Well, because you fell into a hole. 154 00:09:51,990 --> 00:09:56,610 This is like the ITTI game from the 1980s. Lots of holes. 155 00:09:57,210 --> 00:10:01,380 Um, so you fell in to a whole, game over. Um, 156 00:10:01,410 --> 00:10:05,250 but what if they had chosen left instead? 157 00:10:05,520 --> 00:10:08,070 Well that takes them on to the next question. 158 00:10:08,100 --> 00:10:12,000 So that's the option that will allow them to continue along the game. 159 00:10:13,380 --> 00:10:17,250 Now, in this case, we could use an else statement and say, well, 160 00:10:17,250 --> 00:10:20,760 if they didn't choose right then they probably chose left right? 161 00:10:21,270 --> 00:10:25,500 But they could've also chosen like a option that was completely not listed. 162 00:10:25,530 --> 00:10:30,060 They could have just written something like this and it would still trigger the 163 00:10:30,060 --> 00:10:30,893 else statement. 164 00:10:31,350 --> 00:10:35,670 So what we should actually do is to switch it around. 165 00:10:36,180 --> 00:10:41,180 So namely we should say if choice1 is equal to left, 166 00:10:43,110 --> 00:10:45,510 well in that case, then they continue 167 00:10:47,100 --> 00:10:51,030 in the game. But otherwise, namely, 168 00:10:51,030 --> 00:10:54,750 if they chose right or anything else for that matter, 169 00:10:55,110 --> 00:10:57,000 then it's pretty much game over. 170 00:10:57,330 --> 00:11:02,070 So this format makes a lot more sense if you want to continue along the left 171 00:11:02,280 --> 00:11:04,140 side of the branch, this way. 172 00:11:04,770 --> 00:11:09,630 Now another thing that you might've realized because we learned about combining 173 00:11:09,630 --> 00:11:14,630 different conditions is instead of using the dot lower to change the input to 174 00:11:15,420 --> 00:11:16,253 lowercase, 175 00:11:16,620 --> 00:11:21,620 you could have also said if choice is equal to left or if choice1 is 176 00:11:22,350 --> 00:11:26,910 equal to Left, spelt like this, that will both work. 177 00:11:27,060 --> 00:11:27,540 Um, 178 00:11:27,540 --> 00:11:32,540 but I think in terms of succinctness and less code writing, 179 00:11:32,580 --> 00:11:34,650 I think this makes a lot more sense to me. 180 00:11:35,250 --> 00:11:38,760 So I'm going to continue with this version. But if you did it the other way, 181 00:11:38,910 --> 00:11:40,710 that's perfectly valid as well. 182 00:11:41,790 --> 00:11:46,500 Now if their choice1 was left, then they get taken to the next question. 183 00:11:46,500 --> 00:11:48,270 Do you want to swim or do you want to wait? 184 00:11:49,380 --> 00:11:54,380 So let's go ahead and continue the game and create another input. In this input 185 00:11:56,050 --> 00:11:59,050 we're going to ask them a question and say, 186 00:11:59,050 --> 00:12:01,360 you've come to a Lake, 187 00:12:01,810 --> 00:12:06,810 there is an Island in the middle of the Lake. Type "wait" to wait for a boat. Type 188 00:12:11,830 --> 00:12:16,390 "swim" to swim across. Cool. 189 00:12:16,480 --> 00:12:19,780 So we've actually got the same problem as we had before, 190 00:12:19,840 --> 00:12:24,840 namely that this is being interpreted as code rather than as a continuous single 191 00:12:27,190 --> 00:12:30,610 string. So do you remember how we fixed this previously? 192 00:12:31,090 --> 00:12:32,800 And if you got stuck on this, 193 00:12:32,890 --> 00:12:36,310 I recommend having a go at this yourself before I show you the answer. 194 00:12:37,990 --> 00:12:38,320 Alright, 195 00:12:38,320 --> 00:12:43,000 so previously we said we were going to switch it to single quotes instead so 196 00:12:43,000 --> 00:12:47,800 that these double quotes become interpreted as just normal strings. 197 00:12:48,370 --> 00:12:52,150 But of course, we've got this you've, we could, of course, change it 198 00:12:52,180 --> 00:12:56,710 to you have instead of you've, but if we want to escape the string, 199 00:12:56,740 --> 00:13:01,030 we just add a backslash and now everything is colored in this sort of pinkish 200 00:13:01,060 --> 00:13:04,360 color to indicate it's all interpreted as a string, 201 00:13:04,960 --> 00:13:09,460 which is exactly what we did previously. Now in terms of this input, 202 00:13:09,520 --> 00:13:12,280 they're going to type wait or they're going to type swim. 203 00:13:12,340 --> 00:13:15,280 So let's go ahead and lower the casing for it as well. 204 00:13:15,760 --> 00:13:18,940 And then we're going to save it inside a choice, 205 00:13:18,970 --> 00:13:23,970 we're going to say choice2. Now be really careful and mindful of your 206 00:13:24,400 --> 00:13:27,460 indentation because if you wrote it like this, 207 00:13:28,000 --> 00:13:33,000 then it's going to be creating some errors for you because this choice2 input 208 00:13:34,060 --> 00:13:37,840 line has to run when this choice1 is equal to left. 209 00:13:39,040 --> 00:13:41,440 Otherwise we're going to get an indentation error. 210 00:13:42,100 --> 00:13:47,100 So let's go ahead and indent it here to show that this part is inside this if 211 00:13:48,130 --> 00:13:52,030 statement and will only be executed if this is true. 212 00:13:52,780 --> 00:13:55,480 And then we get to check our choice2. 213 00:13:55,780 --> 00:14:00,780 So if choice2 is equal to wait, 214 00:14:01,000 --> 00:14:03,790 then it means that the game will continue. 215 00:14:06,190 --> 00:14:07,630 But else, 216 00:14:07,660 --> 00:14:11,830 so if they typed swim or anything else for that matter, 217 00:14:12,130 --> 00:14:13,720 then the game is going to end. 218 00:14:13,780 --> 00:14:17,320 So we're going to print and tell them that something terrible happened. 219 00:14:17,350 --> 00:14:22,270 "You got attacked by an angry trout. 220 00:14:24,400 --> 00:14:28,540 Game over." Now we can continue along this path, 221 00:14:28,570 --> 00:14:30,520 so we're down to here now. 222 00:14:30,580 --> 00:14:34,900 And the final question we're going to ask the user is which door do they want to 223 00:14:34,900 --> 00:14:35,733 choose? 224 00:14:36,130 --> 00:14:41,130 So here I'm going to use an input to send them the message that "You arrive at 225 00:14:41,830 --> 00:14:45,580 the Island unharmed. There is a house with three doors, one red, one yellow, 226 00:14:45,580 --> 00:14:48,100 one blue. Which color do you choose?" 227 00:14:48,730 --> 00:14:53,730 Now I'm going to save their choice inside a variable called choices, lower 228 00:14:55,040 --> 00:14:58,040 case the answer that they provided, 229 00:14:58,550 --> 00:15:03,350 and finally I'm going to use if, elif and else to check which one they chose. 230 00:15:03,890 --> 00:15:08,890 So if choice3 is equal to red, 231 00:15:10,370 --> 00:15:14,840 elif choice3 is equal to yellow, 232 00:15:17,960 --> 00:15:22,100 elif choice3 is equal to blue. 233 00:15:23,300 --> 00:15:25,040 And then I've got a else. 234 00:15:25,640 --> 00:15:30,080 So here are four possible things that could happen. If they chose red, 235 00:15:30,500 --> 00:15:33,650 then I'm going to tell them that it's game over, 236 00:15:33,860 --> 00:15:37,520 but it's going to be some sort of creative version of game over. 237 00:15:37,580 --> 00:15:40,100 So maybe something like, uhm, 238 00:15:40,160 --> 00:15:45,160 it's a room full of fire. Game over. If they chose yellow on the other hand, 239 00:15:46,460 --> 00:15:49,160 well that's going to be the room where the treasure exists. 240 00:15:49,160 --> 00:15:52,250 So I'm going to print. Um, you found the treasure, you win. 241 00:15:52,850 --> 00:15:56,900 If they chose blue, they also end up with game over. 242 00:15:57,410 --> 00:16:01,310 And I have to give them a different reason. Now, 243 00:16:01,340 --> 00:16:05,330 if you had decided that if they chose anything but yellow, 244 00:16:05,780 --> 00:16:10,460 the way that they're going to game over is the same. Say if, you know, 245 00:16:10,730 --> 00:16:14,360 if you chose red, it's a room full of fire, game over. If you chose blue, 246 00:16:14,360 --> 00:16:17,330 it's a room full of fire game over. Anything else 247 00:16:17,360 --> 00:16:19,760 is also going to be a fire, game over. 248 00:16:20,060 --> 00:16:22,430 Well then you could just use if and else. 249 00:16:22,760 --> 00:16:27,080 But if you wanted each choice or each door to have a different outcome for the 250 00:16:27,080 --> 00:16:29,270 user, say the red door has fire, 251 00:16:29,540 --> 00:16:34,250 the blue door has beasts and if they chose the wrong door then they're going to 252 00:16:34,250 --> 00:16:39,110 get something like you chose a door that doesn't exist, game over. 253 00:16:39,500 --> 00:16:42,110 So can you see that depending on whether 254 00:16:42,110 --> 00:16:46,550 if you want to give the user a different um, print statement, 255 00:16:46,940 --> 00:16:51,170 um, based on their choice, then you would use if, elif, else. 256 00:16:51,560 --> 00:16:54,920 But if you actually just wanted to give them the same feedback, 257 00:16:54,920 --> 00:16:58,730 which is game over, then you could just use if and else. 258 00:16:59,510 --> 00:17:03,140 Now let's run our game and just make sure that it works. 259 00:17:03,290 --> 00:17:08,290 So I'm going to go left because I know it continues and then I'm going to wait 260 00:17:09,080 --> 00:17:13,130 for the boat and that allows me to get to the final condition. 261 00:17:13,220 --> 00:17:15,560 And if I choose yellow, I know that I'll win. 262 00:17:16,100 --> 00:17:20,570 Now if you want to change the formatting because having the input at the end of 263 00:17:20,570 --> 00:17:25,070 the sentence doesn't look as good as letting the user type it on a new line, 264 00:17:25,460 --> 00:17:29,600 like what we've got here, then you can simply, if you remember, 265 00:17:29,630 --> 00:17:31,850 just add the new line, 266 00:17:31,850 --> 00:17:35,450 which is a \n at the end of your inputs. 267 00:17:36,710 --> 00:17:41,270 Like so. So how did you get on with this challenge? 268 00:17:41,330 --> 00:17:44,420 And if you didn't manage to do it right or if you've done it right, 269 00:17:44,810 --> 00:17:46,970 go back and try and modify it. 270 00:17:46,970 --> 00:17:51,970 See if you can add some more conditions or see if you can make the game over 271 00:17:52,080 --> 00:17:54,780 messages a little bit more interesting than what I've written. 272 00:17:55,170 --> 00:17:59,670 See if you can modify and make it really your own. Have fun with that 273 00:17:59,910 --> 00:18:03,480 and in the next lesson, I've got more exciting things coming up for you. 274 00:18:03,840 --> 00:18:08,730 So hopefully you've scheduled some time for tomorrow to complete the next day's 275 00:18:08,730 --> 00:18:11,490 lessons. But for now, it's goodnight from me. 27347

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.