课程: Programming Concepts for Python

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Multidimensional lists

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 pieces 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…

内容