1 00:00:00,000 --> 00:00:01,100 [no audio] 2 00:00:01,110 --> 00:00:02,200 Friends here 3 00:00:02,200 --> 00:00:06,200 we are going to discuss three important string operations. 4 00:00:06,300 --> 00:00:10,400 They are like 'join', 'center' and 'zfill', right? 5 00:00:11,000 --> 00:00:12,600 So how they are going to work? 6 00:00:13,300 --> 00:00:15,300 Let me show you that by taking my 7 00:00:15,300 --> 00:00:17,800 [no audio] 8 00:00:17,800 --> 00:00:19,300 Python Shell. Of course 9 00:00:19,300 --> 00:00:22,300 you can also write in your Python Script, but I am taking 10 00:00:22,300 --> 00:00:23,700 simply Python command line. 11 00:00:24,400 --> 00:00:28,400 Let's say I have a string called "python", right? 12 00:00:28,900 --> 00:00:32,500 See my requirement is, from this 'x', 13 00:00:32,500 --> 00:00:34,900 I mean from this "python" word 14 00:00:34,900 --> 00:00:40,500 I want to create a "python" word by placing between each two 15 00:00:40,500 --> 00:00:42,100 letters, two characters, 16 00:00:43,000 --> 00:00:46,900 a space, I mean I want to create a 'y' data such that it has 17 00:00:46,900 --> 00:00:47,900 to be in this way, 18 00:00:50,500 --> 00:00:55,500 but I want to create that from your 'x' itself. Simply 'y=', 19 00:00:55,500 --> 00:00:59,200 quotations, and inside that just "-", 20 00:00:59,200 --> 00:01:08,600 '.join', then your 'x', so just join space inside of your 'x' between 21 00:01:08,700 --> 00:01:10,000 your characters. 22 00:01:11,000 --> 00:01:12,000 Simply print 'y'. 23 00:01:12,000 --> 00:01:15,200 [no audio] 24 00:01:15,200 --> 00:01:18,000 Right. Otherwise directly you can print. See as of now 25 00:01:18,000 --> 00:01:22,700 I am printing 'x' in this way. Now 'print', you can also do something like, 26 00:01:22,700 --> 00:01:24,600 [no audio] 27 00:01:24,600 --> 00:01:28,400 suppose I am adding "*" between two characters in 28 00:01:28,400 --> 00:01:35,200 my given 'x'. See the output. Or I want to print one by one letter, 29 00:01:36,000 --> 00:01:40,400 then add "\n". You know "\n" means new line. See that, you're 30 00:01:40,400 --> 00:01:44,500 getting your string in multiple lines. In each line one character 31 00:01:44,600 --> 00:01:48,900 because "\n" purpose is. Otherwise, let me add "\t". See the 32 00:01:48,900 --> 00:01:53,300 output. You're adding tab between two characters of your given string. 33 00:01:53,300 --> 00:01:55,300 [no audio] 34 00:01:55,300 --> 00:01:59,700 Right. So this is the importance of your 'join' string. 35 00:02:01,100 --> 00:02:04,300 Right. Fine. Then the next one is 'center'. 36 00:02:05,300 --> 00:02:08,900 See guys, sometimes you have some multiple strings and you 37 00:02:08,900 --> 00:02:13,800 want to print all strings in the center of your terminal 38 00:02:13,800 --> 00:02:16,400 or in the centre of some width of your terminal. 39 00:02:16,400 --> 00:02:20,600 Let's say I have a 'my_str' called simply "python", 40 00:02:20,600 --> 00:02:22,400 [no audio] 41 00:02:22,400 --> 00:02:24,400 and I have one more new string called 42 00:02:24,400 --> 00:02:27,300 [no audio] 43 00:02:27,300 --> 00:02:31,100 "python scripting", and let me take some third string 44 00:02:31,100 --> 00:02:34,100 'my_str3=' 45 00:02:34,100 --> 00:02:37,100 [no audio] 46 00:02:37,100 --> 00:02:38,500 "string operations". 47 00:02:38,500 --> 00:02:41,600 [no audio] 48 00:02:41,600 --> 00:02:45,900 Okay. Now see that I am going to print, 49 00:02:45,900 --> 00:02:47,800 first of all let me take only 'my_str' 50 00:02:49,400 --> 00:02:54,900 '.center'. So all strings I want to print with the width 51 00:02:54,900 --> 00:02:58,000 of suppose some 20 characters. Now, first of all let me print 52 00:02:58,000 --> 00:02:58,900 my first string. 53 00:03:00,400 --> 00:03:04,800 So in 20 spaces your string is there in the middle of that. 54 00:03:05,700 --> 00:03:07,800 Likewise I want to print, 55 00:03:09,200 --> 00:03:11,500 let me use format. All strings at a time 56 00:03:11,500 --> 00:03:13,000 I want, I am going to print. 57 00:03:13,000 --> 00:03:19,700 [no audio] 58 00:03:19,700 --> 00:03:23,100 Right. So in the next line, I want to print your 59 00:03:24,100 --> 00:03:30,300 'my_new_str.center(20)'. 60 00:03:30,300 --> 00:03:31,800 See the output so that you can understand 61 00:03:31,800 --> 00:03:33,300 what is the purpose of this 'center' 62 00:03:33,300 --> 00:03:35,100 [no audio] 63 00:03:35,100 --> 00:03:36,900 Then I want to print your 64 00:03:36,900 --> 00:03:42,600 [no audio] 65 00:03:42,600 --> 00:03:44,900 next variable called "my_str_3 66 00:03:46,300 --> 00:03:50,800 .center(20)', and see the output. 67 00:03:52,300 --> 00:03:56,000 Something missing. Let me see that. Yeah, quotations is missing, 68 00:03:56,000 --> 00:03:57,200 right. See the output. 69 00:03:57,200 --> 00:03:59,100 [no audio] 70 00:03:59,100 --> 00:04:02,500 'center', yeah somewhere spelling mistake. 71 00:04:02,500 --> 00:04:05,000 [no audio] 72 00:04:05,000 --> 00:04:06,000 See. 73 00:04:06,000 --> 00:04:10,000 [no audio] 74 00:04:10,000 --> 00:04:13,100 Nothing is there guys, whatever the length you're giving, first 75 00:04:13,100 --> 00:04:16,500 your Python will take that much length, in that length 76 00:04:16,500 --> 00:04:20,700 it will try to print your string from middle towards left and right. 77 00:04:21,800 --> 00:04:22,800 That's it. 78 00:04:23,700 --> 00:04:28,300 Okay. Now 'zfill', zero add, zero fill. 79 00:04:28,300 --> 00:04:31,500 [no audio] 80 00:04:31,500 --> 00:04:33,900 Let me do one more thing like 81 00:04:39,200 --> 00:04:42,100 'print', let me take simply your string, 82 00:04:43,000 --> 00:04:44,600 I am printing. You're getting something 83 00:04:44,600 --> 00:04:47,500 no, but I want to print this string, 84 00:04:47,500 --> 00:04:50,700 [no audio] 85 00:04:50,700 --> 00:04:54,500 okay, with some 10 spaces. 86 00:04:54,500 --> 00:04:56,300 [no audio] 87 00:04:56,300 --> 00:05:01,700 And anyway your "python" string consists of only six characters, 88 00:05:02,200 --> 00:05:04,100 the remaining four places 89 00:05:04,200 --> 00:05:07,900 I want to pad with 0 towards left. See that. 90 00:05:09,500 --> 00:05:13,600 Total spaces are ten, right. So you are given string length 91 00:05:13,600 --> 00:05:17,200 is six. Remaining four spaces towards left 92 00:05:17,200 --> 00:05:18,800 I want to pad with zeros, 93 00:05:18,800 --> 00:05:22,000 so 'padding', this operation is called actually 'padding'. 94 00:05:24,000 --> 00:05:27,100 Right. This operation is called actually the 'padding'. 95 00:05:27,100 --> 00:05:29,000 [no audio] 96 00:05:29,000 --> 00:05:30,000 Okay, so guys 97 00:05:30,000 --> 00:05:35,100 these are the operation uses of your 'join', 'center' and 'zfill' 98 00:05:36,500 --> 00:05:38,200 Right. Okay guys, 99 00:05:38,200 --> 00:05:39,500 thank you for watching this video. 100 00:05:39,500 --> 00:05:48,000 [no audio]