Transcript:

Hi, everyone, in this tutorial we’re going to talk about Multi-dimensional lists in Python and particularly we’re going to talk about two-dimensional lists. But first I’m going to say few words about lists in Python, For example, let’s say that we have a list of five integer numbers in Python. Let’s call it my list and let’s populate it with few integer numbers. I’m going to do that also in my Triton Idol, I’m going to use the exact same numbers and as you can see this model. This list is an ordinary list in Python and an ordinary list like this. One is one dimensional list, so we can represent this list as one dimension or one row. This list has elements 3 1 or 1 5 PPS 5 elements and being the first element is 0 index of the second one is 1 and so on so starting index is 0 Don’t get confused with working with elements of a list in pipe and now we’re going to give an answer to the main question of this video and that’s how to create two dimensional list in Python. In order to do that first, we need to see what Two-dimensional list is. A two-dimensional list in item is represented as a list of lists. Also, we can say that two dimensional list in item can be represented as lists within list. In the previous example, we get an ordinary one-dimensional list, which can be represented as one row, but in the case of multi-dimensional list inside of putting numbers inside our list we’re going to put new lists within that list, so in this example, we’ll create it one two dimensional list and within our list we have two lists of three elements. I’m going to type that in my Python. I go to dimensional list has a list and within this list we have to list with three elements. First list has a means 3 1 4 and second list has elements. Y 1 5 9 We can say for this 2 dimensional list that he has format 2 times 3 That means that within this list we have two lists with three elements in each list and this 2 dimensional list has two dimensions. The first dimension can be represented by rows. We have two rows inside this list. Each row is a separate list within list and second dimension of all two dimensional list is column. We have three counts in this example. Each column represents one element inside this list. These are two dimensional list has format 2 times 3 and we can represent it and we can think of it. Same as that. We have a table of format 2 times 3 or same as we have Matrix with 4 night 2 times 3 Now, let’s solve few simple Examples. First example, is how to get the and element of the first list of our two dimensional list, so we want to get the second element of our first list first list in our case, yes, index zero and the second element within it has indexed one, so if we want to get this element, we’re going to call our variable, which represents two dimensional list in packets, we’re going to put the index of the rope and in the second brackets, we’re going to put the column of our element also. I want to type that in Python. Idle and let me see. Did we get this element? Yes, we get it now. We have a second example call, for example to get the third element of the second list. We need to get the third element of the second list. The index of second list is number one and index of the third element within our second list is represented by index 2 lets. Try to type that code again in our item. I don’t we want to get the second list. Which has Index 1 and the third element within it, which has index 2 and we get number 9 as the result. Then let’s see in a simple example how to change an element of our two-dimensional list, for example, how to change the first element of the second list. We want to change the first element of the second list. Second list has index 1 and first element of our list has index 0 We want to change that value with some new value in this example with number 8 so we’re going to get the element from our position and we’re going to tend it to it. Some new value. I’m going to type this example in our Python Idol, so we’re going to change the first element of the second list with number eight, and now simply, I just want to call it to see its value and now its value is number eight. In this short lesson We’ve talked about to the Nationalists in item. Thanks for watching, and don’t forget to subscribe to my channel. See you in the next video.