1 00:00:00,780 --> 00:00:01,440 Welcome back. 2 00:00:01,830 --> 00:00:08,430 Let's talk about our next data type, and it's a big one, a very, very useful one. 3 00:00:09,720 --> 00:00:11,340 It's called list. 4 00:00:12,520 --> 00:00:18,310 And list is an ordered sequence of objects that can be of any type. 5 00:00:19,720 --> 00:00:22,640 So you can think of them as string's, right? 6 00:00:22,780 --> 00:00:30,150 We had strings previously that we learned about, except that each sequence of this string well, was 7 00:00:30,460 --> 00:00:34,710 was a string was a letter or number wrapped in quotation marks. 8 00:00:35,660 --> 00:00:43,120 Lists, on the other hand, looks something like this, let's say we create a variable ally and list 9 00:00:43,130 --> 00:00:50,260 we denote with square brackets and inside of these square brackets, we can have different objects. 10 00:00:50,570 --> 00:00:54,480 So, for example, we can have one, two, three, four, five. 11 00:00:55,250 --> 00:00:57,230 We can also have, let's say like two. 12 00:00:57,770 --> 00:00:59,480 And this is going to have a. 13 00:01:03,360 --> 00:01:12,240 See, and it can have any collection of items that we want, we can even mix and match and say that 14 00:01:12,240 --> 00:01:18,600 we have one, two, then a then maybe even the boolean value. 15 00:01:18,900 --> 00:01:19,350 True. 16 00:01:20,220 --> 00:01:23,040 So all of these are lists. 17 00:01:24,140 --> 00:01:33,020 Now, lists are extremely important, and in other programming languages, you might have heard the 18 00:01:33,020 --> 00:01:34,580 word or phrase. 19 00:01:35,090 --> 00:01:43,460 So in Python lists are a form of Arae and later on, when we get into the modules section of the course, 20 00:01:43,670 --> 00:01:47,020 we will talk about the difference between lists and arrays. 21 00:01:47,150 --> 00:01:54,380 But if you are coming from a different programming background, then lists are like a in your language. 22 00:01:55,520 --> 00:02:03,020 A collection of items now the neat thing about lists is that it's the first data structure that we're 23 00:02:03,050 --> 00:02:07,280 learning now, what is a data structure? 24 00:02:08,360 --> 00:02:12,110 Data structure is a very important concept and programming languages. 25 00:02:12,650 --> 00:02:21,980 It's a way for us to organize information and data into, let's say, a folder or a cupboard or a box 26 00:02:22,340 --> 00:02:27,050 so that these data structures can be used with different pros and cons. 27 00:02:27,200 --> 00:02:34,280 For example, you have a fridge where you store your food and fridges are really, really good at putting 28 00:02:34,310 --> 00:02:37,520 your food inside, keeping it cold and then taking it out. 29 00:02:37,940 --> 00:02:39,830 Or you might have a backpack. 30 00:02:39,830 --> 00:02:43,100 A backpack is really, really good to stuff everything in there. 31 00:02:43,100 --> 00:02:46,450 But when you're looking for things in a backpack, it's really, really hard. 32 00:02:46,820 --> 00:02:54,080 So you can think of data structures similar to that, a container around your data that has different 33 00:02:54,080 --> 00:02:58,790 pros and cons of accessing that data, removing that data, writing data. 34 00:02:59,030 --> 00:03:01,610 But that's something we'll get into a little bit later. 35 00:03:02,180 --> 00:03:10,880 The key here is that the square brackets allow us to contain information and data like strings, integers, 36 00:03:11,090 --> 00:03:15,490 floats, if we want to booleans into a contained fashion. 37 00:03:15,800 --> 00:03:17,600 So let's think of a good example here. 38 00:03:17,810 --> 00:03:19,670 What if we had a shopping cart? 39 00:03:19,850 --> 00:03:26,000 Let's say we're Amazon here and then Amazon has the Amazon shopping cart. 40 00:03:26,510 --> 00:03:29,420 And in here we can collect different things that we want. 41 00:03:29,720 --> 00:03:32,900 Maybe we collect some, I don't know, notebooks. 42 00:03:33,830 --> 00:03:34,460 And you know what? 43 00:03:34,520 --> 00:03:35,570 Let's get some gadgets. 44 00:03:35,570 --> 00:03:38,660 Let's get some maybe some sunglasses. 45 00:03:39,530 --> 00:03:41,900 We can add different items here. 46 00:03:41,900 --> 00:03:45,770 Different strengths, different data into this cart. 47 00:03:46,920 --> 00:03:52,370 And now, just like we saw in String's, we can access the Amazon card in different ways. 48 00:03:53,760 --> 00:04:01,500 For example, I can access it again with square brackets and simply say, I want to item zero, so if 49 00:04:01,500 --> 00:04:02,490 I print here. 50 00:04:04,170 --> 00:04:05,460 And do Amazon cart. 51 00:04:07,160 --> 00:04:09,800 Look at that, I get notebook's the second item. 52 00:04:12,060 --> 00:04:13,600 I get sunglasses. 53 00:04:14,490 --> 00:04:16,170 What about the third item? 54 00:04:18,900 --> 00:04:21,870 NOC list index out of range. 55 00:04:23,350 --> 00:04:28,450 But this should make sense now, this is a list where we're accessing the index of. 56 00:04:29,340 --> 00:04:35,750 But it only contains two items, so if we're going zero one to the third item, nothing exists. 57 00:04:35,770 --> 00:04:38,100 So our program says that doesn't work. 58 00:04:38,100 --> 00:04:39,030 You're doing something wrong. 59 00:04:40,160 --> 00:04:48,500 And just like strings, these list items are in memory in their separate bookshelf, right, but one 60 00:04:48,500 --> 00:04:54,500 right next to each other so we can go zero, one, two, three, four or five, so on and so forth until 61 00:04:54,500 --> 00:04:55,550 the list ends. 62 00:04:56,330 --> 00:04:56,720 All right. 63 00:04:56,870 --> 00:05:00,050 Let's learn about lists a lot more in the next video. 64 00:05:00,490 --> 00:05:00,720 Bye.