Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Welcome back.
Let's talk about something called escape
sequence in Python let's comment this out and let me ask you a question.
What if we wanted to have a string that tells me let's say the weather.
And here we want to write it's sunny.
You see how the highlighting change here because I want to say it's with an apostrophe S..
But python is reading this and saying OK this is the start of the string and this is the end of the
string.
And then I have no idea what this is.
And then we're starting a string again.
How can we fix this.
Well we can add a double quote string instead.
And this now works.
But what if for some reason we also wanted to add it's kind of sunny in quotation marks.
Well now we have another issue.
So how can we solve this because in human language we have double quotes and apostrophes what we can
use escape sequences here and this is a little hard to understand at first but it's simply adding a
slash like this so the one right above your enter on the keyboard so this slash when Python goes through
it is going to say all right whatever comes after this I recognize this symbol whatever comes after
this I'm going to assume it's a string.
So now if I do backslash here and then backslash here it's going to say hey Python I'm letting you know
whatever comes after this is a string I'm letting you know whatever comes after this is a string and
then I'm letting you know what comes after this is a string so that when we print the weather everything
is printed nicely.
Awesome.
Now this escape sequence can be used in multiple ways.
For example if I want to have an actual backslash Well I can go like this.
And because it's saying whatever comes after this is a string it's going to assume that this is a string
now.
So if I run this you see that we get this backslash and there's a few other neat tricks a can do with
it.
For example one of it is the backslash T.
What does that mean.
Well let's remove this for now.
There you go the backslash t remember well it's out of space in here.
So we can distinguish it is going to say hey whatever comes after this.
I want you to add a tab.
This is a special meaning here.
So if I click on run you'll see that it's added a tab spacing to my string.
Another one is using n or a new line.
So let's leave t here and then add a backslash n and then say hope you have a good day.
What do you think will happen here.
Fact like run I have a tab from the backslash T.
And then I have a new line after kind of Sunny because I do the backslash and which denotes a new line
so that this shows up on a new line.
Now these escape sequences are hard to see at first but they're pretty much available in all programming
languages they use strings.
So if you come from another language this shouldn't be that strange to you.
If it's your first time seeing this you just need to get used to this syntax and every once in a while.
Go to the Python documentation and just type in escape sequences and you'll see all the ones that we
have.
These are the main ones that you need to know.
All right.
More to learn in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.