1
00:00:00,000 --> 00:00:05,990
Python has an extremely rich set of string methods, over 40 of them last I counted.

2
00:00:06,000 --> 00:00:08,990
What we've covered here are the essential ones.

3
00:00:09,000 --> 00:00:11,990
And I'd like show you how to find the rest of them and how to use them.

4
00:00:12,000 --> 00:00:12,990
It's really quite straightforward.

5
00:00:13,000 --> 00:00:18,990
Here we have the Python documentation page or the Python Standard Library.

6
00:00:19,000 --> 00:00:21,990
And we'll notice this is section 5, Built-in Types.

7
00:00:22,000 --> 00:00:26,990
And down here we see this link of 5.6.1 String Methods.

8
00:00:27,000 --> 00:00:28,990
And here's a complete list of all the string methods.

9
00:00:29,000 --> 00:00:31,990
Like for example, here is this center one.

10
00:00:32,000 --> 00:00:35,990
And we see that center it takes with and an optional fill character and it

11
00:00:36,000 --> 00:00:38,990
returns a centered string of length width.

12
00:00:39,000 --> 00:00:42,990
And padding is done using this specified fill character. Default is a space.

13
00:00:43,000 --> 00:00:49,990
So if I had a string, 'this is a string', and I wanted to center it on say 80

14
00:00:50,000 --> 00:00:55,990
character string, I would simply say new = s.center(80) like that.

15
00:00:56,000 --> 00:00:57,990
And now I have a new string.

16
00:00:58,000 --> 00:01:00,990
And we see that this new string is 80 characters wide.

17
00:01:01,000 --> 00:01:04,990
I can check if I want to. length of new is 80.

18
00:01:05,000 --> 00:01:08,990
And we see that the string from my original string is centered there.

19
00:01:09,000 --> 00:01:11,990
Like I said, there are over 40 of these different methods.

20
00:01:12,000 --> 00:01:14,990
And here's the entire list and they are all very well documented.

21
00:01:15,000 --> 00:01:15,990
It's really simple.

22
00:01:16,000 --> 00:01:18,990
It's not in a terribly technical language.

23
00:01:19,000 --> 00:01:22,990
And so I encourage you to take the time and at least read through this one and

24
00:01:23,000 --> 00:01:24,990
get an idea for what is available.

25
00:01:25,000 --> 00:01:27,990
And then refer to it when you need one.

26
00:01:28,000 --> 00:01:30,990
That makes it really easy for you to have these tools at your disposal without

27
00:01:31,000 --> 00:01:34,990
having to memorize everything, without having to go through a lot of detail on

28
00:01:35,000 --> 00:01:36,990
the ones that you are not going to use very often.

29
00:01:37,000 --> 00:01:38,990
So use the documentation in this case.

30
00:01:39,000 --> 00:01:41,990
There is a great wealth of string methods available.

31
00:01:42,000 --> 00:01:52,000
And I encourage you to become familiar with them and use them.

