 What's going on guys? Root at nullshell.com here with you today and we are going to be checking out some more Python code. Now in this video we're going to be looking at something called lists. Now lists are a really, really intricate, detailed and kind of like a quirky subject. And in Python it's very, very big. I feel like big is probably the best way to put it. There's a lot you can do with these. They're interesting, there's a lot to cover, but they're some of the most useful things I think I have ever seen. So let's get started though. In Python it really is just a bunch of variables combined together. Like it kind of really is a list of data. They can hold whatever sort of data type they might like to have. You can have as many different data types as you want inside of a list. And they're usually called arrays. Like in other languages they're called arrays. Like in C and C++, maybe in Java and PHP and Ruby or anything else. I don't know about Ruby, but I mean usually these are called arrays. Python just likes to call them lists because I don't know, they're different or something, whatever. Python is special. In math you would consider these things to be matrices. They have that sort of like that look and that appeal because you're holding multiple pieces of information. You can nest lists and get into like sub layers and completely different dimensions of the time space continuum. And we look at the world in a completely different paradigm. But that's a whole other story and we're going to be checking that out more and more as we go in depth. But I want to introduce you guys to a lot of the things with these, but there is a lot to cover. So bear with me. This might take a while and I might even forget some things. But hey, let's get started with Idle. Today we're going to be working on the interactive shell though. I don't want to have to bother creating a new program or leaving a new script because I just kind of want to show you what you can do with these. The syntax is simple. It's just as if you were creating a variable, but the array is encased in these brackets. So let's call the variable new list, we'll set it equal to, and then inside these brackets we're going to have the data that we want to have. Now the data is separated by commas. You can have, let's say, two, maybe six, maybe nine, that sort of thing. And I'll get my semicolon here and that's done. So now we have new list. It's full of integers, two, six, and nine. But like I said, we were able to put different things in there. What if we did it with 2.6534 or something? And then nine, I don't care. New list does that exact same thing. What if we did it with a ton of strings? Just like John, Kevin, Mike, and now we have new list and there it is. But if we combine these, we can still have Mike, two, and then that's 6.534. You can still have that. It works that perfectly. It works that same way. So you can have an integer, a float, and a string. You can have as many of these as you want. You can have a list that is potentially, let's see, control... I want to do Alt P. That's what I want to do. And just do this over and over and over again. And now you have a new list of all these interesting things. Now, you can have duplicates of these variables, obviously. It's kind of a silly idea to do that. I don't know why you would want that. But yeah, when you're defining a list, you are separated by commas. So this is kind of a little bit of a nice quirk with Python. I think it's a little bit almost of an accident with the language, because let me open up a new window for a moment here. If I... let's get a new list equal to... and I'm going to make this a multi-line thing. I'll save it as a file.python. This is sort of temporary, though. I don't plan on doing too much with this. But if we have new list, we can type in John. And say, Brian, Chris, and that sort of thing. And now you have your new list. Now we can print new list. We can run that one. It's perfectly fine. We get John, Brian, and Chris. Now, the thing is, with Python, or at least in other languages, you would usually have to leave out that final comma, because you don't have another value. That's just silly to have something else. In Python, it does allow you to have that last comma, even if there's no value coming after it. Now, this might not seem like a big deal to you at the moment, but if you have really big lists and you're using this sort of style, you're spacing it out line by line. If you just want to copy and paste stuff, Chris, Chris, Chris, Chris, you don't have to worry about adding that extra comma on. And that's probably something very stupid to you at the moment, but I don't know. Maybe it's something that I'm in love with and everyone else in the world doesn't care for. Okay, new subject. Let's get a different... First of all, let's clear idle for a little bit. Let's get a diff list. A different list. We'll have you nine. Kevin. Yeah, let's do Kevin. I don't care. And then 7.4, 10, 11. You can have as many of these values as you want. You could have a list with only one actual value. That's kind of silly, but I suppose if you want it to be dynamic and versatile, because you could keep adding things to these lists. You could potentially... B list, we can set you to be 3, 15. You could use your assignment operators and you could add things on. So A list plus equals B list. If you check out A list again, you have 12, and then you have those 3 and 15 added on there. So you could append is a terminology most people use with that. You could append things onto that list. And that's kind of awesome. That's going to be really, really useful, especially very soon. Okay, though. That's something else. Let's see what we got here. Lists have this really special functionality to be able to index these sort of things. And that's the new vocab word for today, indexing. When you have all these things stored inside this list, they are each their own sort of variable, because you can retrieve that data by a specific number. So except the thing is the computer counts them in an interesting way. It starts the first index, or the first thing that you have in your list is counted at 0. The next thing is 2. The next thing is... I'm sorry, the next thing is 1. I probably just screwed up the entire tutorial. No, but see the first thing is labeled as 0. The next thing is labeled as 1. The next thing is labeled as 2. The next thing is labeled as 3. It almost subtracts 1 from the way humans would think of it. So if we have diff list, and we're trying to retrieve a variable from this list, we're going to use those brackets immediately after the variable name, and we're going to type in the number that we want. If we do diff list 0, which in our case is going to be 9, we get 9. Awesome. Absolutely awesome. If we do diff list, let's say 1, we get Kevin. Fantastic. It's indexing the way it should be. If we do... I suppose that's all I really need to talk about for this. But another really interesting thing that Python allows you to do is it lets you index things with a negative number, like at the backwards bit of this. What if we tried indexing the list with a number that's arbitrarily humongous, 99? That might throw us an error because it's out of the range, and there are ways to test, obviously, how many things are in the list, and I'm going to get to that later on because we're going to try dissecting that sort of idea and that mindset eventually along with a lot of other things. But back to what I was saying with the negative indexing, you can use diff list negative 1. Negative 1 will actually give you 11 because it's that last term. If you were using the index of 0, it would just give you that first term, obviously, but if you use negative 1, it goes from the back and works backwards. You get 11. If you do that again with negative 2, you get 10. If you do that again with negative 3, you get 7.4 because it's going back 1, back 1, back 1 again. And you could entirely reverse almost your list. And that's an interesting idea. But yeah, that does... I feel like that's all that I want to talk about in this video. Actually, no, because I want to jump in with one last idea and one last concept. When you guys look at strings, we're going to have a little bit of a blast back to the past year. When you guys look at strings, this is a string. You've got a string here. Strings are able to be indexed. Let's set a string variable. String is equal to... This is a string. There's always... This is a string. And now you can use string 0 and we'll get t. You can do it one more time, string 1. You'll get that lowercase h. What if we use those negative ones now? What if we use negative 3? What do you think you guys will get? Do you think you'll get i? Good. If you thought you'd get i, you were right. You understand this concept, because you're using the number minus 1 if you're looking at it in the human's perspective. You're using this number minus 1 to get the current character at the position of that string. And that works that same way with lists, except you get the current index or the current element or value in the list. If you look back at diff lists and you're looking at 0, you get 9. If you look back at 1, you get Kevin. And you have the option to have so many different sort of data types. You can have these integers. You can have these floats. You can have these strings. What if you actually even put a list inside of a list? What if you had a list point to a completely different list or index things with different numbers in different ways? And being able to index things is so cool. It is so awesome because you can use these with loops. Let's say you were running a for loop and you were trying to see how many items were in a list. Or at least getting the value of each thing inside of a list using a loop. This is an interesting idea and that's what we're going to be talking about in the next tutorial because lists are so powerful and so awesome. The thing is there are lots of functions and lots of things you can do with these that we're going to cover real soon and I'm actually going to try and dissect them and show you guys how you would do that using the pure code and the real linguistics of Python. So we're going to try and look at some of the basic functionality of these data types. Since these data types are a little bit more advanced than the regular numbers and text that we started with at the beginning of the video series, this is why I saved them for a later portion. And because we're going to be manipulating these with for loops and while loops and if conditional statements and that sort of thing, I wanted to get those pieces of language out of the way before I introduced these more in depth and sort of broad topics. So I really hope you guys get down with lists a lot though because they're so versatile and they can hold so much information, they're so dynamic, you can add and remove things if you need to. You can have, like, you can number the way that you're working in your code and that sort of thing. It's just grand. But hey, enough of me rambling, I've gone off on a tangent. Thank you guys so much for watching, thank you for listening. Now that we're trying to get down to the nitty gritty, I hope you guys are still as into this and as passionate as I am. I'll see you in the next tutorial. Bye.