From the course: Python Data Structures and Algorithms
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Understand the 2D list data structure - Python Tutorial
From the course: Python Data Structures and Algorithms
Understand the 2D list data structure
- [Instructor] 2D Lists are an important data structure with many applications. Some of the more common ones are listed on the slide. So, for example, any situation where we have a grid such as screen pixels or, in our case in this project the representation of game boards and mazes and such like. Also, mathematical programming, where if we want to represent matrices and basically whenever you have any kind of tabular data, so the kind of data you would store in a table like in a spreadsheet. There's other places where 2D lists are very useful. And there's a few others listed. A 2D list can be thought of as a list of lists. As with 1D lists, in Python, the elements can be of mixed type, although this is fairly uncommon. So take a look at this visual representation. We have a list definition in code here: my_list is equal to a list containing a list, another list, and another list. And beneath that, we have a visualization or a visual representation of how that would be stored inside…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.