From the course: Programming Foundations: Real-World Examples

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Multidimensional lists

Multidimensional lists - Python Tutorial

From the course: Programming Foundations: Real-World Examples

Start my 1-month free trial

Multidimensional lists

- Basic lists are fairly easy to understand because they're just a simple sequence of items. However, things can get a bit more complicated when we embed lists inside of other lists to create two-dimensional or even three-dimensional lists which can be a bit harder to visualize. That's one of the reasons I like to think of objects in a list as cars in a parking lot. To index my car in a two-dimensional parking lot, I need to know two pieced of information. First, I need to know which row I'm parked on and then I need to know at which spot along that row I parked. The same concept can be extended to three-dimensional lists of lists of lists and that's like a multi-story parking garage. To index my car in there, I need to know three things. First, which floor I parked on. Next, I need to know which row on that floor I parked. And finally, which spot along that row, on that floor, I'm parked in. Now, my analogy has to end here because a four-dimensional parking lot doesn't exist in real…

Contents