All language subtitles for 019 Syntax Errors-subtitle-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
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-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

Original subtitles

1

Hey welcome to this new lecture! This is

the most important lecture you have had

3

so far in this course, so please try to

make the most of it and this is actually

5

a new video that I am adding to the

course. I didn't have this lecture a few

7

times ago so I had this quite a while

after I published the course and until

9

now I had explained this concept, so the

errors little by little in other

11

lectures but I felt that was not enough

and I was seeing that students were

13

still having difficulties in

understanding and dealing with errors in

15

Python so I decided to make a dedicated

lecture for errors in Python. So here we

17

are and I said this is the most

important lecture because you know we

19

we learnt about functions and strings

and numbers until now in the previous

21

videos and these are individual concepts

that you know you'll learn, now or later you'll

23

learn functions and strings and etc, but

if you don't know how to read an error

25

how to to understand an error and deal

with it if you don't know that you will

27

have trouble dealing with everything

every other object like functions and

29

streams and numbers etc. So understanding

and error and knowing how to deal with

31

it, how to fix it is very important and

even the most experienced programmers

33

they make errors in their programs. The

difference is that they know how to read

35

these errors. How to understand and

fix them, but everyone makes errors. So if

37

an error shows in your program don't

panic just for all the instructions that

39

I'll give you in this video on how to

fix the error so that's what this

41

lecture is about. So what is an error

anyway? An error in a program is a bug

43

that causes the program to function

incorrectly. Now in Python we have

45

basically two types of errors. We have

syntax errors and we have exceptions.

47

Let's first focus on syntax errors and

let's forget about exceptions. We'll go

49

to exceptions after we explain

syntax errors. I have this code here and

51

actually this is a Python file. This is

the icon showing on a Mac so currently

53

I am on a Mac computer but that doesn't

make the slightest difference. No matter

55

where you are on Linux Windows or Mac

everything is the same. So I have the

57

terminal here and let me go ahead and

execute this program. This has a few

59

errors so let me show them. On Mac you

can call Python 3 with the python3

61

command, on Windows you can just call

python or whatever command you are

63

using. You can also use any editor that

you like and so errors.py is the

65

name I gave to the script, execute.

So this is now an example of a syntax error

67

and this is the entire body of the error

message and this is very important, so

69

whenever you get an error the first

advice I give you is don't panic just

71

focus on the error. Read it line by

line just like you're reading a poem or

73

whatever so the first line of the error

points you to the name of the file that

75

has the error. In this case is errors.py.

Then you have a comma and after

77

the comma you have the line where the

error occurred.

79

So it's line 3 and you can see that line

3 is this one here but you also have for

81

your convenience Python prints out the

line in the terminal so int 9. Here is

83

where the error is and just after that

you have the type of the error so it's a

85

syntax error, you also have other types

of errors such as name error, type error,

87

but those are exceptions and I'll

explain later why we call them

89

exceptions, so this is one type of error

a syntax error and the others are

91

exceptions. So this is the type and then

you have the description after the colon.

93

Sometimes the description is more

specific more detailed. This time is just

95

invalid syntax.

So you have to figure out where

97

you did some error where you

missed some syntax of your program.

99

And you also have this arrow here pointing

upwards and the arrow points you even at the

101

token that the error is occurring or at

the end of the token, so a token is you

103

know, this is the token in this case 9.

So it can be a number, it can be string,

105

anything, so at this point this is

pointing at this, at the token but

107

it could also be like that.

999 save the script, execute. In this

109

case you see that it's pointing you at

the end of the token. So here's, around

111

here you have an error now and I know

that int is actually a function and

113

functions important they need to have

brackets so you need to pass 999 inside

115

brackets like that and you leave that.

Save and execute again. All right, you've

117

got another error but don't panic again.

This is my advice always, instead

119

read the error it says file errors.py

the file line 5, oh line 5 this time.

121

So it's not line 3 anymore which means

that line 3 was fixed so what Python is

123

doing is it's going through all the

lines one by one from top to bottom, it

125

checks the first line it says: "Oh it's

fine, no error there". Goes to the next

127

line no error, goes through the third

line, no error this time, fourth line is

129

also fine, and fifth line has an error so

again it's a syntax error and this one

131

is more specifically described so

missing parentheses in call to print.

133

Note that you get this error only if you

are on Python 3. If you are on Python 2

135

this won't be an error because in Python

2 print was a statement and was not

137

function so with statements like

return or print in Python - you didn't

139

have to pass brackets. This syntax would

be correct.

141

So again this arrow here is pointing you

and the token so we just add

143

brackets there, ctrl s to save the script

and execute again. This time we don't get

145

any error so the script executed fine

and print it out the output here.

147

1 2 3 so we had 3 print functions

printing out output. This doesn't return

149

any output because we're not printing

anything so this just gets the function

151

input and produces some output but

doesn't print anything. If you want to

153

print it, you want to pass the print

statement function there. There could

155

also be other types of syntax errors and

you know such as you want to define a

157

least 1, 2, 3, but instead of

closing it with a square brackets, you use

159

a round bracket instead like that. Save

the script and execute and you see that

161

you got a syntax error, invalid syntax at

line 5 which is this one in here. Again

163

the arrow points you at the token so you

need to figure out how to fix this round

165

bracket here and you know that. You need

to close it with a square bracket so

167

that should fix the issue. So these are

Ao that's about syntax errors. They are

169

very easy to fix. In the next lecture I

will explain exceptions so see you there!

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