Hello everybody and welcome back.
And in this story all will cover something called lists now basically lists is as it says it can be
used to store for example multiple values of a number or a string.
So let's say you for example wanted to store three different numbers into one variable.
You would do that using lists so you would specify all those three numbers in all those brackets divided
by commas.
We already saw an example of creating a list in the previous videos.
But right now let's see what we can do with lists and how to create them.
So let's open up our Python interpreter so just typed your python.
And right now what you want to do is basically let's first of all create a string list.
So a string list is basically a list containing words.
There is not really any special specification for that to use one type here.
String lists or basically name it anything you want.
I will just name it string list equals then these kinds of brackets and then what you need to specify
here is basically just the strings that you want to put in the list.
So let's say we put right here shallow comma and then world comma then open bracket then open a repository
once again.
So what closed the apostrophe open apostrophe what is happening and then we close the bracket.
So right now we specified a list.
So let's print it out string list and you can see the values of our string list which is how the world
what is happening.
So let's see what we can do with lists.
For example you can select each part of the list or each value of the list by specifying its number.
So if you for example specify string list and then in brackets one.
So just like this string list don't make space between these two.
Just type here these brackets and then 1 it will print out the second version or the second word in
our list which is world.
Now you might be asking why does it print the second word in our list if we specified one in the brackets.
Well basically this is counted as the zero word it car.
It starts counting from zero.
So this is zero.
This is one this is two.
This is three and this is four.
That's why we got the word world.
Once we specify the one in our brackets.
If we for example specify zero we would get the shallow words in our list so you can specify that.
You can also specified for example one and then two dots which will specify all the words from one to
the end.
These two dots represent the end of the list as we can see we have right now.
World what is happening there is no where to see yellow since yellow is before 1 if you specified three
and then two dots equals print out everything from the Third Word which in our case is is.
So it prints out just is happening.
You can also do it the other way around so you can just type first the two dots and then after that
three which I'll specify or which will print out all the words before the third word so we will long
forget how the world what.
And we will not be printing out what is happening after that.
So that is another string or list manipulation you can use this can also be applied for string.
So for example let's just select a string to be hello.
And then if you just type your string one you will get the letter E.
If you just type your string and then one and then until the end which is packed with these two dots
right here you will get Ello right now since we only specified all the letters after the first one including
the first one.
So h as a number 0 letter will not be included in this.
You can also do it as it set in the reverse way so let's say until two we only get h e so this can be
implied both for strings and both for lists.
Now this is important to remember the syntax for this since we will be using it also in our backdoor
creation.
So that is something you should know but right now let's get back to the list.
So let's be clear the screen right a little bit so input so that soil system cleared.
And right now let us find the commando specification for our string list.
So here it is.
We specified once again.
Now let's see for example how we can remove a certain letter from B or not better a certain string from
our list.
You can do that with using this so string list we specify the name of our list and then dot remove and
then open normal brackets and then between the double quotes we specify the word that we want to remove.
So let's say we want to remove the world and we press here enter.
And if you just type your string list once again so string list you will see right now our list doesn't
have world in it.
We only have yellow what is happening right now.
We do not have the world in our list.
So that is how you can remove it.
And right now if you specify a string a list of one you will no longer get the world as a word since
right now the first word which is since it's counted from zero is what and not world anymore.
So that is another thing you should know.
Now for example if you want to append something to the list you can use the dot append command and then
the name or the string that you want to append to but be aware that this will only add the word or your
string to the end of the list.
So if we wanted to add world once again.
So string underscore list which is name dot append open brackets close brackets and then to double quotes
in here.
We want to add world we press enter.
But right now if we just type your string list once again you will see that right now it says hello
what is happening world.
The world is no longer in the second position now or list it is at the last position in our list.
So not append is used.
Once you want to know to actually add a string to the end of the list now in order to remove a string
from the end of the list you can use dot pop which basically just opps or removes the last word into
left.
So string list dot pop and then open brackets right here.
You do not need to specify anything basically since it will remove the last string from list.
You just press your enter and it will pop up the world string so string list once again and we no longer
have the world string in it.
We popped it up.
We did dot pop function.
Now function is also something that we will have to cover since we will be making our own functions
in our program.
So that is something that we will do in the next video functions are very important especially once
you code are bigger problem programs it.
They're useful for us to actually navigate better travel code and to actually shorten our code a little
bit.
Once you use a function you can only call it with one line and you do not need to rewrite it 10 times
in order to perform the same task for something.
So that would be about it for the lists in this area.
As I said in the next one we will be covering functions.
So I hope I see you there and take care by.