1 00:00:00,450 --> 00:00:03,640 We'll come to an overview of our Python business today. 2 00:00:03,660 --> 00:00:07,110 We will talk about how to work and manipulate strings in Python. 3 00:00:08,520 --> 00:00:12,450 Let's start with making a string lower or uppercase in Python. 4 00:00:23,260 --> 00:00:28,690 We have a lowercase string now, let's capitalize it using the upper function. 5 00:00:43,680 --> 00:00:47,550 Now it's reverted back to a whole lower case using the lower function 6 00:00:57,010 --> 00:00:57,280 cool. 7 00:00:58,560 --> 00:01:02,960 Now let's take a look at the split function since it's very important in Python. 8 00:01:04,140 --> 00:01:06,480 The split function will split in a string. 9 00:01:06,490 --> 00:01:09,170 You happen to illest by default. 10 00:01:09,180 --> 00:01:11,840 It will split your string using space as a delivery. 11 00:01:12,810 --> 00:01:13,870 Let's see how it works. 12 00:01:14,790 --> 00:01:17,190 I'm going to create a variable that holds the string. 13 00:01:17,190 --> 00:01:18,060 Hello World. 14 00:01:26,730 --> 00:01:33,450 Notice there is a space between hello and world and that's how our split function will split our string 15 00:01:33,450 --> 00:01:36,090 into one list with two elements. 16 00:01:48,150 --> 00:01:50,250 Let's check the time of our variable now, 17 00:01:55,020 --> 00:01:57,870 as you noticed, is change from string to a list. 18 00:01:58,710 --> 00:02:02,070 Now we can only access the first element using number zero. 19 00:02:11,930 --> 00:02:17,420 Let's see how we use this with function to split usernames and from passwords in an output that we have 20 00:02:21,080 --> 00:02:24,590 now, we split this output with this function into two parts. 21 00:02:25,460 --> 00:02:30,080 We will use the first part with zero and then we split it again. 22 00:02:30,080 --> 00:02:32,780 But this time we will use Colen as a delimiter. 23 00:02:57,290 --> 00:03:01,940 Now we get this, we get the second element, which is number one, and that should give us our username. 24 00:03:07,750 --> 00:03:13,240 We can all we can do all of that again, but in the same line, let's try that. 25 00:03:35,250 --> 00:03:35,530 Nice. 26 00:03:35,880 --> 00:03:39,180 Let's do it again and save it in a different variable called user. 27 00:03:48,490 --> 00:03:53,880 Now, let's do the same with the password, but keep in mind, the password part is the second element. 28 00:03:54,670 --> 00:03:58,290 If we split it so it will be element number one, not zero. 29 00:04:12,160 --> 00:04:14,290 Looks like it didn't like our key. 30 00:04:16,340 --> 00:04:18,210 Let's try it with a password. 31 00:04:19,650 --> 00:04:20,050 Nice. 32 00:04:24,100 --> 00:04:29,700 Now let's take a look at the replace function when we create our own PIN testing tools. 33 00:04:29,740 --> 00:04:34,690 We sometimes need to read a file and replace or insert a word in that file. 34 00:04:35,470 --> 00:04:36,540 Let's see an example. 35 00:04:45,190 --> 00:04:47,830 And create a variable of the string python. 36 00:04:48,610 --> 00:04:51,280 Now let's replace the word python with Ruby. 37 00:05:03,910 --> 00:05:11,260 We sometimes have a new line in our string, but we can see it first, let's see how how we identify 38 00:05:11,260 --> 00:05:14,780 a new line, our strength, and then how do we remove it? 39 00:05:16,120 --> 00:05:18,250 Let's print our variable, my. 40 00:05:22,060 --> 00:05:23,860 If you notice here, we have a new line. 41 00:05:24,340 --> 00:05:27,340 But normally sometimes you don't see that. 42 00:05:28,720 --> 00:05:35,710 But if we print our string using the R e park or represent function, we can see everything in it. 43 00:05:41,740 --> 00:05:47,920 Now we can see the new line, it's a backslash, and at the end, let's remove this new line at the 44 00:05:47,920 --> 00:05:50,020 end of our string using the strip function. 45 00:05:58,060 --> 00:05:58,460 Nice. 46 00:05:59,770 --> 00:06:04,900 We can also remove it using the replace function and replace the new language that empty quotes. 47 00:06:05,350 --> 00:06:06,190 Let's try that. 48 00:06:27,180 --> 00:06:28,150 It is gone. 49 00:06:29,290 --> 00:06:34,070 We get the same result, but the strip function only removes new line at the end of the string. 50 00:06:34,570 --> 00:06:39,670 So if we now changed a new line to be in the middle of our string, it won't work. 51 00:06:40,030 --> 00:06:45,780 And that's when we use the replace function and instead we have reached the end of this lesson. 52 00:06:46,120 --> 00:06:46,690 Thank you. 53 00:06:46,690 --> 00:06:47,830 And see you in the next one.