1 00:00:00,540 --> 00:00:01,150 Welcome back. 2 00:00:01,710 --> 00:00:04,410 Let's talk about something called escape. 3 00:00:06,790 --> 00:00:07,480 Sequence. 4 00:00:11,520 --> 00:00:19,020 Let's comment this out and let me ask you a question, what if we wanted to have a string that tells 5 00:00:19,020 --> 00:00:23,070 me, let's say the weather and here we want to write? 6 00:00:25,060 --> 00:00:26,500 It's sunny. 7 00:00:28,990 --> 00:00:37,450 Hmm, you see how the highlighting change here, because I want to say it's with an apostrophe s but. 8 00:00:38,540 --> 00:00:43,400 Python is reading this and saying, OK, this is the start of the string and this is the end of the 9 00:00:43,400 --> 00:00:47,480 string, and then I have no idea what this is and then we're starting a string again. 10 00:00:48,550 --> 00:00:50,050 How can we fix this? 11 00:00:50,950 --> 00:00:59,860 Well, we can add a double quote string and said, and this now works, but what if for some reason 12 00:00:59,860 --> 00:01:02,200 we also wanted to add it's. 13 00:01:03,620 --> 00:01:07,100 Kind of sunny in quotation marks. 14 00:01:07,610 --> 00:01:11,870 Well, now we have another issue, so how can we solve this? 15 00:01:11,870 --> 00:01:17,120 Because in human language we have double quotes and apostrophes. 16 00:01:19,000 --> 00:01:21,400 Well, we can use escape sequences here. 17 00:01:23,000 --> 00:01:30,020 And this is a little hard to understand at first, but it's simply adding a slash like this. 18 00:01:31,020 --> 00:01:34,560 So the one right above your enter on the keyboard. 19 00:01:36,310 --> 00:01:43,000 So this slash, when Python goes through, it is going to say, all right, whatever comes after this, 20 00:01:43,030 --> 00:01:47,380 I recognize this symbol, whatever comes after this, I'm going to assume it's a string. 21 00:01:49,360 --> 00:01:57,190 So now if I do backslash here and then back here, it's going to say, Hey. 22 00:01:58,130 --> 00:02:02,360 Python, I'm letting you know whatever comes after this is a string, I'm letting you know, whatever 23 00:02:02,360 --> 00:02:08,630 comes after this is a string, and then I'm letting you know what comes after this is a string so that 24 00:02:08,690 --> 00:02:11,150 when we print the weather. 25 00:02:13,420 --> 00:02:16,750 Everything is printed nicely, awesome. 26 00:02:18,020 --> 00:02:25,670 Now, this escape sequence can be used in multiple ways, for example, if I want to have an actual 27 00:02:25,670 --> 00:02:29,690 backslash, well, I can go like this. 28 00:02:29,870 --> 00:02:35,090 And because it's saying whatever comes after this is a string, it's going to assume that this is a 29 00:02:35,090 --> 00:02:35,600 string now. 30 00:02:35,690 --> 00:02:42,470 So if I run this, you see that we get this backslash and there's a few other neat tricks they can do 31 00:02:42,470 --> 00:02:42,790 with it. 32 00:02:43,310 --> 00:02:48,350 For example, one of it is the backslash t. 33 00:02:50,050 --> 00:02:51,460 Hmm, what does that mean? 34 00:02:51,820 --> 00:02:53,980 Well, let's remove this for now. 35 00:02:54,460 --> 00:02:55,020 There you go. 36 00:02:56,600 --> 00:03:02,540 The back tee, remember Willis, outerspace in here so we can distinguish it, is going to say, hey, 37 00:03:03,050 --> 00:03:06,730 whatever comes after this, I want you to add a tab. 38 00:03:06,770 --> 00:03:08,350 This is a special meaning here. 39 00:03:08,900 --> 00:03:10,280 So if I click on Run. 40 00:03:11,370 --> 00:03:15,510 You see that it's added a tab spacing to my string. 41 00:03:16,910 --> 00:03:27,320 Another one is using GNH or a new line, so let's leave it here and then add a backslash and and then 42 00:03:27,320 --> 00:03:27,800 say. 43 00:03:29,250 --> 00:03:32,060 Hope you have a good day. 44 00:03:34,160 --> 00:03:36,530 What do you think will happen here if I click run? 45 00:03:38,390 --> 00:03:39,830 I have a tab. 46 00:03:41,000 --> 00:03:49,280 From the backlashed and then I have a new line after kind of sunny because I do the backslash and which 47 00:03:49,280 --> 00:03:53,310 denotes a new line so that this shows up on a new line. 48 00:03:54,140 --> 00:04:00,290 Now, these escape sequences are hard to see at first, but they're pretty much available in all programming 49 00:04:00,290 --> 00:04:00,760 languages. 50 00:04:00,770 --> 00:04:01,580 They use strings. 51 00:04:01,850 --> 00:04:05,780 So if you come from another language, this shouldn't be that strange to you. 52 00:04:06,020 --> 00:04:11,920 If it's your first time seeing this, you just need to get used to the syntax and every once in a while 53 00:04:12,050 --> 00:04:17,690 go to the python documentation and just type in escape sequences and you'll see all the ones that we 54 00:04:17,690 --> 00:04:18,070 have. 55 00:04:18,110 --> 00:04:20,180 These are the main ones that you need to know. 56 00:04:21,280 --> 00:04:21,710 All right. 57 00:04:21,850 --> 00:04:23,410 More to learn in the next video.