All language subtitles for 010 [Interactive Coding Exercise] Debugging Practice_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
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
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 Download
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,030 --> 00:00:00,863 To begin, 2 00:00:00,930 --> 00:00:05,820 I want you to locate the day 1.2 debugging exercise. 3 00:00:06,960 --> 00:00:10,380 And now, as you did before, go ahead and read through the instructions. 4 00:00:10,740 --> 00:00:15,740 Be mindful that the output must match the example output precisely. 5 00:00:16,410 --> 00:00:19,980 And when you hit run, this is the outcome you're looking for. 6 00:00:20,430 --> 00:00:22,890 So there's quite a few things broken here, 7 00:00:23,130 --> 00:00:28,130 but I want you to have a go at fixing each line individually and pulling out the 8 00:00:28,590 --> 00:00:31,860 bugs from the code. So pause the video now and give that a go. 9 00:00:36,710 --> 00:00:37,130 All right. 10 00:00:37,130 --> 00:00:40,610 So how did that go? If you haven't got your computer in front of you, 11 00:00:40,610 --> 00:00:45,350 if you're traveling, if somehow you can't access the exercise, just pause 12 00:00:45,380 --> 00:00:46,790 and when you've got time, 13 00:00:46,820 --> 00:00:49,430 then complete the challenge and then come back to the course. 14 00:00:49,850 --> 00:00:53,300 It is so important that you actually do some hands-on stuff. 15 00:00:53,540 --> 00:00:57,440 And I stress that this is the only way that you are going to become the rock 16 00:00:57,440 --> 00:01:02,300 star coder that I know you can be. Let's take a look at the code below. 17 00:01:02,870 --> 00:01:06,410 You can see that when we run our code as it is right now, 18 00:01:06,590 --> 00:01:08,300 we get a new error. 19 00:01:08,780 --> 00:01:12,650 And this is going to point to the first of many errors in this file. 20 00:01:13,340 --> 00:01:17,930 And in this case, it tells us that on line three, 21 00:01:18,170 --> 00:01:22,970 so this one right here, at around this position 22 00:01:22,970 --> 00:01:27,740 or somewhere around here, um, as denoted by the little caret sign, 23 00:01:28,130 --> 00:01:31,790 there is a syntax error. If we study this closely, 24 00:01:31,790 --> 00:01:36,200 you can see that the code highlighting seems to be suggesting that all of this 25 00:01:36,200 --> 00:01:41,060 is code, but this is somehow text. So what's going on here? 26 00:01:41,510 --> 00:01:44,900 Well, notice that we've only got one double quote. 27 00:01:45,200 --> 00:01:48,770 So it thinks that what comes after this is the text, 28 00:01:49,190 --> 00:01:52,850 but what comes before it, it thought it was just a continuation of code. 29 00:01:53,330 --> 00:01:54,500 So to fix this one, 30 00:01:54,530 --> 00:01:59,530 all we have to do is add a double quote right here. That changes the text to the 31 00:02:00,200 --> 00:02:04,010 color that we're used to and this fixes this line. 32 00:02:04,190 --> 00:02:08,930 So if we run our code now, we should get a different error. And indeed we do. 33 00:02:10,190 --> 00:02:13,580 The next one tells us that on line five, 34 00:02:13,610 --> 00:02:17,720 so this one right here, there is an indentation error. 35 00:02:17,780 --> 00:02:22,610 There's an unexpected indent somewhere around here on line five. 36 00:02:23,120 --> 00:02:26,360 So let's take a look at line five and there you go. 37 00:02:26,420 --> 00:02:31,280 There's a little bit of extra space between the print and the beginning of the 38 00:02:31,280 --> 00:02:32,113 line. 39 00:02:32,240 --> 00:02:37,240 So now that we've fixed that one, let's click run. And it will point to 40 00:02:37,970 --> 00:02:40,910 another line of code that's broken. And in this case, 41 00:02:40,910 --> 00:02:43,340 it says on line seven, 42 00:02:43,400 --> 00:02:46,190 which is here where there's actually no code, 43 00:02:46,520 --> 00:02:51,260 there's the unexpected EOF while parsing. What does this mean? 44 00:02:51,650 --> 00:02:53,030 Well, if you're not sure, 45 00:02:53,060 --> 00:02:58,060 then go ahead and paste it into Google and let's take a look at what people say 46 00:03:01,240 --> 00:03:05,470 on Stack Overflow. So as this person, 47 00:03:05,740 --> 00:03:09,970 very kind, Felix, um, has explained, this index error 48 00:03:10,090 --> 00:03:11,110 unexpected EOF 49 00:03:11,110 --> 00:03:16,030 while parsing means that the end of your source code was reached before all 50 00:03:16,030 --> 00:03:20,650 code blocks were completed. What is a code block? Well, 51 00:03:20,680 --> 00:03:23,920 this is a code block because it's a print function, 52 00:03:24,160 --> 00:03:29,140 it has a beginning and it has an end. But what does this line not have? 53 00:03:29,620 --> 00:03:31,690 Well, it's got two open parentheses, 54 00:03:32,020 --> 00:03:34,630 but only one closing parentheses. 55 00:03:34,960 --> 00:03:39,960 So the computer thinks that you are going to continue writing something and then 56 00:03:40,150 --> 00:03:44,380 close it off at the end, which is not the case. In fact, 57 00:03:44,410 --> 00:03:49,410 what has happened is we simply have an extra misplaced open parenthesis. 58 00:03:51,700 --> 00:03:53,710 And now if we delete that and hit run, 59 00:03:54,010 --> 00:03:57,520 you'll see that we have everything printed. 60 00:03:57,940 --> 00:04:01,300 But at this point, notice how on line four 61 00:04:01,480 --> 00:04:03,310 which is the line that we haven't fixed yet, 62 00:04:03,820 --> 00:04:08,820 it prints string concatenation is done with the 'blank' sign. 63 00:04:10,090 --> 00:04:12,430 Whereas in fact, it should say plus sign. 64 00:04:13,360 --> 00:04:18,360 And even though we don't see any errors being printed in our console, 65 00:04:19,269 --> 00:04:23,590 you'll see that we have an output mismatch because I'm expecting to see this 66 00:04:23,590 --> 00:04:27,460 line, the String Concatenation is done with the "+" sign, 67 00:04:27,910 --> 00:04:28,743 but here, 68 00:04:28,990 --> 00:04:33,990 the output doesn't have that part. It's missing this part. 69 00:04:35,140 --> 00:04:39,700 So there's one last thing that you need to debug. And that is of course, 70 00:04:39,730 --> 00:04:40,630 on line four. 71 00:04:41,290 --> 00:04:46,290 And what's happening here is we have this part being interpreted as a string, 72 00:04:47,200 --> 00:04:49,540 this part being interpreted a string, 73 00:04:49,960 --> 00:04:54,960 and it thinks that this plus sign is just us concatenating 74 00:04:55,420 --> 00:04:57,280 these two parts together, 75 00:04:57,760 --> 00:05:01,540 which is why it printed out like this. But in fact, 76 00:05:01,640 --> 00:05:06,220 we wanted to print out is this as text down here. 77 00:05:06,850 --> 00:05:11,850 So what we have to do is to change this outer apart from double quotes 78 00:05:12,400 --> 00:05:14,320 into single quotes. 79 00:05:14,830 --> 00:05:18,370 And now you can see when it highlights this part, 80 00:05:18,460 --> 00:05:21,640 it's all the same color including the plus sign. 81 00:05:22,420 --> 00:05:26,110 Now it sees this as a complete string, 82 00:05:26,590 --> 00:05:30,850 and it's not looking at this as if it's code. So now if we run our program, 83 00:05:30,880 --> 00:05:33,580 you can see the entire sentence being printed out. 84 00:05:34,810 --> 00:05:38,650 So if you've completed the challenge and you've gotten everything right, 85 00:05:38,740 --> 00:05:41,290 then you're now done with this exercise. 86 00:05:41,950 --> 00:05:46,930 If you got stuck and you want to have a look at the solution, as always it's down 87 00:05:46,930 --> 00:05:47,763 here, 88 00:05:48,040 --> 00:05:53,040 and it might be useful to have a look at this page to see where you might've 89 00:05:53,380 --> 00:05:56,620 missed something or where you might've gotten something wrong. 90 00:05:57,730 --> 00:06:01,270 So I hope you enjoyed this code exercise. In the next lesson, 91 00:06:01,330 --> 00:06:04,060 we're going to learn about a new type of Python function, 92 00:06:04,150 --> 00:06:08,560 which is the input function. So for all of that and more, I'll see you there. 8443

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