Welcome back.
Let's talk about our next data type.
And it's a big one.
A very, very useful one.
It's called List.
And list is an ordered sequence of objects that can be of any type.
So you can think of them as strengths, right?
We had strengths previously that we learned about, except that each sequence of this string, well,
was was a string was a letter or a number wrapped in quotation marks.
Lists, on the other hand, looks something like this.
Let's say we create a variable ally and lists we denote with square brackets.
And inside of the square brackets we can have different objects.
So for example, we can have one, two, three, four, five.
We can also have, let's say, Ali two.
And this is going to have a.
Be.
See.
And it can have any collection of items that we want.
We can even mix and match and say that we have one too.
Then a then maybe even the boolean value.
True.
So all of these are lists.
Now lists are extremely important and in other programming languages you might have heard the word arrays.
So in Python lists are a form of array.
And later on when we get into the modules section of the course, we will talk about the difference
between lists and erase.
But if you are coming from a different programming background, then lists are like arrays in your language.
A collection of items.
Now, the neat thing about lists is that it's the first data structure that we're learning.
Now, what is a data structure?
Data structure is a very important concept in programming languages.
It's a way for us to organize information and data into, let's say, a folder or a cupboard or a box
so that these data structures can be used with different pros and cons.
For example, you have a fridge where you store your food, and fridges are really, really good at
putting your food inside, keeping it cold, and then taking it out.
Or you might have a backpack.
A backpack is really, really good to stuff everything in there.
But when you're looking for things in a backpack, it's really, really hard.
So you can think of data structures similar to that, a container around your data that has different
pros and cons of accessing that data, removing that data, writing data.
But that's something we'll get into a little bit later.
The key here is that the square brackets allow us to contain information and data like strings, integers,
floats if we want to booleans into a contained fashion.
So let's think of a good example here.
What if we had a shopping cart?
Let's say we're Amazon here, and then Amazon has the Amazon shopping cart.
And in here we can collect different things that we want.
Maybe we collect some, I don't know, notebooks.
And you know what?
Let's get some gadgets.
Let's get some maybe some sunglasses.
We can add different items here, different strings, different data into this cart.
And now, just like we saw in strings, we can access the Amazon cart in different ways.
For example, I can access it again with square brackets and simply say I want to item zero.
So if I print here.
And do Amazon cart.
Look at that.
I get notebooks.
The second item.
I get sunglasses?
What about the third item?
Nope.
Lyst index out of range.
But this should make sense now.
This is a list where we're accessing the index of.
But it only contains two items.
So if we're going zero one to the third item, nothing exists.
So our program says that doesn't work.
You're doing something wrong.
And just like strengths, these list items are in memory in their separate bookshelf.
Right?
But one right next to each other.
So we can go zero one, two, three, four, five, so on and so forth until the list ends.
All right.
Let's learn about lists.
A lot more in the next video.
Bye bye.