Hello, everyone.
In this particular session, we will be discussing about strains we would discuss about various dring
operations like strip split, replace, case change, string formatting and slicing.
So let's begin with it.
Let's start with transcreation post.
A string is a sequence of characters, so a string can have a single character, say, E..
A string can also have a sequence of characters or just a word.
See what?
A stream can be created by a single code, double or triple code.
So let's see how we can create a string by we have just seen how to create a single code.
So we'll see how to create string using double code.
So I'm creating a sentence.
So this is using double quotes and you can see the string has been created with the same format, but
only the syntax is different.
We have used a similar code here and here.
We have used a double.
Another way of creating a string is using triple quotes.
So here I am using triple code, so I'm saying this is.
Month two lines train.
This.
Go on and.
And let me save this particular string in say that.
So if your friend said.
Now you can see that the multiline string is coming as a multiline comment.
Now, let's say we have a particular word which has gotten it.
So this is a.
Ordinary.
But not so.
Ordinary.
Multiline strength now you can see here I have begun my strength using a triple code, so this understands
that this double code, which has been used inside the same Din's and the single code which has been
used inside the sentence, is a part of the sentence and is not defining on the string inside this.
So it will consider this as a single string.
And this is we get as a response so we can use Dubofsky string, triple string or single code for the
string creation's so that we can distinguish between the codes which are being used in Dohnanyi.
So let's see if I have a single code which is being used inside the string, then I can use either a
multiline string or a double code to start my string so that this particular code would be considered
as a part of the string.
Same applies for double code.
So in case I have a double code in my string, I can use a single code for starting and ending my string
so that the machine would understand.
Then this is a part of a sentence.
The next thing which we can do is we can concatenate multiple strings.
So let's say I create a string named X, which is.
Hello.
My name is Monty.
And why, as.
What is your name?
Now, what I can do is with this particular string, I can combine these strings, so let's run this
particular piece of code and I can concatenate these by using said is equal to X plus Y.
So this would concatenate this and those forms would be.
Hello, my name is Monty, and what is your name?
So these have been concatenated together.
I can also do this in opening statement so I can say something like Brent.
X plus.
Code space, hello.
In brackets, let's say.
And I can also.
Add another string here, say.
So when I do this, it will contain whatever I give in and say this now this is possible because these
are all strings now.
Same thing I can do with numbers.
So let's say I do this with.
Numbers being two plus nine, so this will give me 11 as a result, because now it would understand
that I have given in numbers and I'm using a plus operator.
So this means that I don't want to concatenate these together.
I want to add these numbers.
But in case I want to concatenate these together, what I can do is.
I can simply put these in quotes, and now it would seem that this is a string.
And it would concatenated these together.
But in case you want to try something like let's say you want to try something with a string on a number,
in that case, let's see what would happen.
Now, look, we've got a string to and I'm giving mine as a number, so when I ran this particular piece
of code, I get the error, saying it can only concatenate string, not integer to a string.
So we will not be able to concatenate string with a number.
You can only concatenate string with a string or we can add two numbers here.
So this is what we can do in case of string.
So this is one thing which you need to always remember that in case you want to concatenate two numbers,
you will have to convert them industry and then concatenate in case you want to add two numbers, you
can directly use them and in case you want to concatenate two strings, then that would be possible
by using plus operator, which would act as a concatenated here.
Let's create a string Z, as this is a very I long I string, I like this string now I have created
the string and I want to split the string on I.
So what I can do is.
I can write something like Z dot split, and inside this I can give the character or special character
on which I want to split.
So I'm giving a.
So this gives me the split with I now, in case I don't want to split down, I want to split on the
space, I can give a space here and it would split on space.
If you don't give anything, it will simply don't split because we have not given anything.
So if you just don't give anything, it will split on space by default.
So these are the different combinations we can try.
Now, another thing is using strength, so let's use drip.
So for using strep, what we can do is let's create another string Z and have a lot of spaces in the
beginning.
Now we have a lot of spaces in the beginning.
Let's see something.
Something.
And a lot of spaces, so this is my Z and I want to strip this, so what I can do is I can do something
like Z is equal to Z dot strip.
And when I don't give anything, it will strip off all the white spaces from the right side and the
right left side.
So what I can do is I can simply print.
Zent quickly, so once I do this, it have it has stripped of all the spaces from the beginning and
the end of the thing, what I can do is I can do a strip.
From the left side or the right side, so here I am stripping from the left side.
So it gives me this, but I won't be able to see the spaces here.
Because if you can see, I have highlighted the spaces here.
Another function which we have is replace, so how we can use replaces, we can simply seize it.
Dodd plays.
And in the replace function, we will give the character or the string that we want to replace.
So let's say we want to replace some.
With.
Nothing.
And.
This would give us nothing instead of something, the next thing.
Now, this could be done in a long string, also in a smaller string.
Also, you can replace a larger string.
Also, you can replace just one character also.
So it is completely up to you.
And you can see it has replaced all the occurrences of this particular string in Z.
The next thing which we can do is we can change the keys.
So to change the keys, what we can do is begin.
First of all, I can introduce one more thing to you, which is then function Leane function with just
give the length of said so Lent is 19 characters so you can come visit Zettl.
One, two, three, four, five, six, six devices 12.
So we are discussing mode something something that this will have one, two, three, four, five,
six, seven, eight, nine, and that would be 18 plus one.
Space's 19.
So let's learn about the case, so for keeps changing, what we can do is we can say something like
said Dot Apple.
So it will change the case of Z to Apple, we can see something.
Now, let's assign this to Z also and then protect.
So now the case of Z has been changed to uppercase.
Now, if I want to convert this into a lower case, I can see Z dot lower and it will convert it to
lowercase.
I can also see Z.
Dot.
Capitalize, Z, dot capitalize and Z dot capoulas would capitalize the first character in the string.
Next week, a new string formatting, how do you string formatting is we already have so let's see the
world values of X Y.
So what we can do is let's I want to print.
Hello, my name is Monty, and I can add something more to it.
So what I can do is.
I can either concatenate these and use these as a single string on the thing, what I can do is I can
create placeholders in my strings or that what I will have to do is I will say print.
And inside prison, I can see something like this is.
Oh, sentence.
My name is.
The blank space.
Hello.
Blacks face.
Now, this is the Indicus train.
Apart from that, I can include a dot for MACD.
Which will take off your argument and the argument would be whatever I want to fill in these holy places.
So if I want to fill in, let's say this is this, then I want to add my.
The next thing which I want to add is.
Munsie And the next thing which I want to add is Montay again.
So once I've done this, you see the blanks which I have introduced by these holy places, have been
filled by the values which I have provided in the for Mike.
I can provide numbers also.
I can provide strings also.
I can provide variables also.
That is completely up to my wish.
Another thing, what I can do is instead of using these holy places and of without any police numbers,
what I can do is I can remove this.
So because manses repeating so I don't really want to write it again and again.
So instead of having this, I can say zero.
One.
And one, so this would.
Simply take the values from the indexes, so the zeroth index is mine, so it considers zero here and
the first index is Monte, so it puts Monte in both of these places.
Now, in case I want to switch the places, I can also do something like this.
I will put this here, and instead of zero, I can please one and instead of one, I can play several.
So the index says is what is important to you.
So now, because I have given my team the zero the index, I am putting zero here.
So this is about string formatting.
We will learn about string slicing in the next section.