‫Now let's move on to lists.
‫Lists are very similar to a string, except that each element can be of any type in the strings.
‫Each element was a character, but in lists, each element can be of any type.
‫So to define a list, we have to use square records.
‫So if I write l1l1 is our variable name.
‫Then in a square grid, if I write one, two, three, four.
‫One, two, three, four, five and one.
‫This one is our list.
‫To check right type.
‫And one.
‫It is showing that the type of one character is list.
‫To print all its value.
‫We write print one.
‫And we are getting all the values that one is containing.
‫Just like a strings.
‫We can also use the same slicing techniques to manipulate lists.
‫So if I write.
‫And one square record.
‫Zero.
‫This will give me element present at the zeroth location, which is one.
‫So here one is that location zero two is a location one.
‫Three is the location.
‫Two, four, three and five at four.
‫You just like a string.
‫I can use colon to select multiple elements, so if I write zero, Colon three.
‫It will give me the first three elements here.
‫The location three is excluded, so I will get elements presented.
‫Location zero.
‫Location one and location two three is excluded, just like slicing in the strings.
‫We can also use steps.
‫So if I write 11.
‫Now, if I want to select all the elements, I will just write Colon.
‫Then I will write another colon.
‫So first argument was for the starting location.
‫Second argument was for the stopping location.
‫And the third argument is for the steps.
‫We are not giving a starting and stopping location since we want all the elements and now we are defining
‫a step as two.
‫So it will give me all the alternate elements of my list.
‫So again, it is ignoring two and four since we provided a step of to.
‫It is not necessary for this to have all the elements of same type.
‫You can assign different types of elements in a single list.
‫So if I write, I'll do equal to the square record.
‫One comma.
‫If I want to write a string, I will write a double quotation.
‫A.
‫Coma.
‫If I want to provide floating point numbers, I will write 1.0.
‫And if I run this.
‫My two is created and the data type of my first element is and second element is a string.
‫And the third element is load.
‫But we can assign all this in a single list as well.
‫So if we want to check, we can check using the type operator.
‫If I type now inside a two, I want the data type of first element, so I will write zero and it is
‫the end because one is our end.
‫If I write type.
‫Redo the square bracket one.
‫Which is a string because our A is in double quotation and we have provided a string as a string we
‫write to.
‫Our two is a list.
‫That's why if we just write a type of L2, it will show us list.
‫We can also provide list as an element of another list.
‫So if we write l three equal to.
‫I do.
‫Coma.
‫One.
‫Coma, 2.0.
‫If we run this command.
‫So we have provided list a little list inside all three.
‫So if we print all three.
‫Here.
‫Our first element is a list, which is L2, and our second element is and third element is flawed.
‫So just to check if we write type of.
‫And three.
‫Common zero.
‫This is showing us as list because we have provided L2 inside of L3.
‫Now.
‫We have mentioned how to select the first element of all three.
‫We can just write all three and in record we can write zero.
‫This will give us the first element.
‫My first element is a list.
‫So how to select first element of that list.
‫We can write all three.
‫And square record.
‫I will first write zero.
‫Right now I am accessing my first element, which is a list.
‫Now, if I want the second element of this list, I will write in a square.
‫Record one.
‫If I run this command, it will give us.
‫Director.
‫A These types of lists are called nested lists because we have lists inside the list.