All language subtitles for 007 String Manipulation and Code Intelligence.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
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
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

Original subtitles

1

All right guys.

2

Let's get back to learning about a few more things that we can do with strings.

3

You saw in the last lesson that if we wanted to print things on individual

4

lines, then we actually had to write them a few times, right?

5

We had to write print, um,

6

on three lines if we wanted it to be printed one, two, three,

7

like so. Now in this lesson I want to show you a method where we can do the same

8

thing, but by using a single print method.

9

So saving ourselves a few characters.

10

So the way that we would create a new line is by writing a backslash and the N

11

character.

12

And now if I go ahead and write hello world again afterward and I hit run,

13

or you can always use the shortcut, which is command + enter on Mac or control +

14

enter on Windows.

15

And you can see that once that line of code has been executed,

16

I've got hello world printed on two separate lines,

17

separated by this pink \n and character,

18

which gets replaced by a new line.

19

So go ahead and give that a go and see if you can create another one.

20

Remember though,

21

it's a backslash and not a forward slash but the syntax highlighting should help

22

you. All right,

23

we can simply just add another \n and remember that unless you want a

24

space to appear right before where your hello world appears,

25

you actually don't want any gaps between each of these lines.

26

There we go. We've got the same result as before,

27

but now using only a single print statement and creating some new lines with the

28

\n.

29

Now one of the other things that we can do with strings is we can concatenate

30

them.

31

What this means is we combine different strings so that they will be added to

32

the end of another string. Here's an example.

33

Let's say that we had the word hello and I wanted to add my name to the end of

34

this word to make it a single string. Well,

35

I can combine two strings by simply using a plus sign. So I can write "Hello"

36

+ "Angela". Now here's a question. When this runs,

37

what do you think it will look like? Do you think it'll write Hello

38

Angela or hello Angela, all in one word? Let's see what happens.

39

You can see that these two strings have now been combined into one and there's

40

no space in between because we don't have a space character anywhere in here.

41

Pause the video and see if you can add a space in between.

42

Alright,

43

so there are two ways that you can do this or maybe three actually. You could add a

44

space to the end of hello, you could add a space to

45

the beginning of Angela or you can actually continue using string concatenation

46

by simply adding another string in between these two

47

and this one is just a space. So now when I run my code,

48

you can see the space gets inserted and this long thing gets combined into a

49

single string that looks like this

50

once this bit of the code gets executed.

51

If we think of strings as a string of connected characters,

52

then string concatenation is simply taking those separate strings of characters

53

and merging them into one. Now,

54

this is a good point to mention that in Python programming spaces are really,

55

really important.

56

And what I mean by this is not so much the spaces that are inside strings like

57

this one, but the spaces that you add in your code.

58

So here, my print statement, if I hit the backspace,

59

you can see that nothing happens. I can't go any further back.

60

But if I added a space or if I added a tab using the TAB key,

61

then you'll see that when I try to run my code, I actually get an error.

62

And the type of error this time is not a syntax error anymore.

63

It's now an indentation error.

64

And it says that there's an unexpected indent at this position right at the

65

beginning of the print statement. So when you're coding in Python,

66

it's really important that you start off all of your code at the beginning of

67

the line and that you don't accidentally have any spaces or any tabs that you've

68

inserted in front of the line of code.

69

And the next time you get an indentation error,

70

then you'll be able to look at where that error is and hopefully you'll be able to

71

either use Stack Overflow or just remember what this error message means and

72

you'll be able to fix your code.

73

Now this is the second error that we've come across.

74

The last error was a syntax error for example,

75

when we forgot to add the end double quotes.

76

And this one is called a syntax error and this one is called an indentation error.

77

And as I mentioned before, while you're coding,

78

you are going to make lots and lots of these errors and other ones.

79

This is the only sure thing that we know.

80

So it's great that you're already learning about them and recognizing them.

81

But how can we prevent this from happening in the first place? Well,

82

paying attention while you're typing helps, but we all get tired and sometimes,

83

especially when I'm coding at night, sometimes even when I look at my own name,

84

it looks like it's spelled wrong and I can't figure out left and right.

85

So in most cases, text editors have a lot of helpful features.

86

If you go into the settings bar here and you scroll all the way to the bottom,

87

you can see that there's something called Code Intelligence. And code

88

intelligence is something that is going to help you auto-complete some of the

89

functions like our print function here and give you some helpful information or

90

hints as you type.

91

So let's go ahead and change it to enabled and close down our settings pane.

92

And you can see now if I, for example, forget to add my double quotes,

93

then I already start to get a little red squiggly line here and a little red bit

94

in the right hand side of the scroll bar.

95

And if I hover over the red squiggly line,

96

you can see that it gives me the error that I would get if I ran my code right

97

now. And so it reminds me that, Oh yeah,

98

there's maybe something about my string that's not quite right.

99

And you can also just Google these error messages and see it in Stack Overflow

100

to remind yourself of what the error might be relating to.

101

And I can fix it without having to run my code and having it break.

102

Because remember that when you're writing large programs,

103

it's not just going to be one line of code.

104

You can have multiple lines of code each with their own errors.

105

For example, this one might be missing a double quote,

106

this one might be missing a plus sign,

107

this one might have the print function misspelled.

108

The next one might have a indentation that's not meant to be there,

109

and when you run your code like this, it'll only give you the first issue.

110

Once you fix that issue,

111

it'll continue to the next issue until you've fixed everything,

112

and this is really painful. But with code intelligence enabled,

113

every time we make an error such as an indentation error like this,

114

then we'll be able to hover over it and you'll see unexpected indent.

115

So we'll be able to fix that. If we forget to close off our print statement,

116

then we'll get a little squiggly line next to it.

117

And if we say misspelled our print statement,

118

we'll also get errors telling us that undefined name or it doesn't know what

119

this 'prnt' is and the syntax highlighting also changes and everything should

120

all help you to avoid mistakes and write good solid code.

121

So now it's time for another code challenge.

122

And in this code challenge,

123

I've got a whole bunch of broken code for you and your job is to debug or remove

124

the bugs from the code and make the code run without any errors.

125

This word debugging actually comes from a story where back in the 1980s a

126

moth actually flew into one of the early computers and it got electrocuted

127

unfortunately for the moth and for the programmer,

128

it meant that his code wasn't performing as he would expect it to.

129

So he actually had to go into the computer, pick out the moth,

130

and fix the wires so that it would work again.

131

Now we don't have any moths flying around in our code, thankfully,

132

but what we do have to do is we have to pick out the errors so that our code will

133

run in the way that we expect it to without any errors.

134

So head over to the next lesson and try out your first debugging exercise.

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