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 strings right.
We had strings 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 list we denote with square brackets and inside of these 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 ally 2 AND THIS IS GOING TO HAVE A B C and it can have any collection of
items that we want we can even mix and match and say that we have one two 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 arrays 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 bullying us into a contained fashion.
So let's think of a good example here.
What if we had a shopping cart let's say where Amazon here and then Amazon has the Amazon shopping cart
and then 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 fine print
here and do Amazon cart look at that.
I get notebooks.
The second item I get sunglasses.
What about the third item
no list.
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 0 1 to the third item nothing exists.
So our program says if that doesn't work you're doing something wrong.
And just like strings these list items are in memory in their separate bookshelf.
Right but one right next to each other.
So we can go 0 1 2 3 4 5.
So on and so forth until the list ends.
All right.
Let's learn about lists a lot more in the next video by.