So we get the value python hacking now, this could loop through each character in the string python
hacking and concatenate it to the end of the string, which is stored in the building as MediaVest.
So at the end of the building is holds the complete string.
Although this particular string concatenation seems like a straightforward technique, it's very inefficient
in Python because it's much faster to start with the blacklist and then using append list method.
So when you're done building the list of the particular string, you can convert that list with a single
string variable by using a joint method.
OK, so instead of this particular code that we have done, we will write down similar code, which
will do the same thing as this particular code has done.
So over here we will create the building as is equal to open closed bracket.
Then we are creating four seven in C Biton hacking open the for loop then here we are seeing building
is set up in the value of C one to it.
Then
let's go here and then we see building as is equal to single code or join the value of building us and
then we give operand command building.
It also gives us the same output.
So using this approach to build up string instead of modifying a string will result in a much faster
programs.
And you can see differences of time by two approaches using the time, the time method.
Now, just to test this, we will create a new file in the ED window and we will enter certain coding.
So let us go for a new file and the first thing we would do is we would import your time.
Then we would see start time.
One is equal to save time or time.
Then we run for the one in the range and we will give here in say ten thousand.
OK, a bigger number for it.
Then we have your C malingers is equal to the first method that we had used for Iven in the range of
ten thousand.
We are seeing malingers plus is equal to say concatenate X and after this you run Alperin.
Come on the c c string concatenation colon comma.
Here you put in the value of time or time minus the start time one that you had.
So the exact time would be put in there.
Now once we have done this again, we would create this start time to is equal to again.
So time or time and again here we would take the two in the range, same range.
We will take four.
That will get the exact difference we have.
Your building is which is equal to a list now and again here we are saying even in the range of ten
thousand again.
And once we open up this year, we say building is not.
We use the append matter and we say append the value of X, after which we say building S is equal to
join the value of building us.
And finally we give up trying to come on c c list, appending colon and reprint here time or time minus
start time to in this case.
Now let us save this just to rebuild or save it in our E drive.
An advanced level course and let us give your name, see?
Best string dog fever.
And now if we try to run this module.
It will take a certain time because we have given a range of ten thousand there, so we will get how
the string concatenation works and we will also get to see how the string list works there.
So let us just wait and see the output, what it comes for, string concatenation as well for the string
or the list of spending that we have used their serial string.
One calculation, look how much time and again, let us now check for the list of spending to work and
get the similar output.
So list up only to how much time it is.
A lot more differences if you find out this.
So now we have set here the variable.
If you look at this, the string program, which is your start time one over here, the first variable
that is sitting as the current time and the cold runs here for ten thousand times and it upends the
ten thousand characters to a string using a concatenation and then prints the time it took to finish
the concatenation.
Then the program resets your or sets another time in start time to be able to the current time again
runs the code and used this time the list of spending method to build a string of the same length and
then put in the total time to finish.
Now every computer made for what time you're getting.
So in this case, if you just look at the output, it has taken 50 for about seconds for the string
concatenation.
But using the list up and process, it took the same task in just 18 seconds.
So if the program builds a lot of strings, using list can make a program much faster.
So now we will use the list up and join forces to build strings for the remaining programs in this particular
session.
So we'll continue Murong discussion of all the programs that we have already done in the next session.
That's it from this session.
Thank you very much.