5.16 Two-Dimensional Lists
Lists can contain other lists as elements. A typical use of such nested (or multidimensional) lists is to represent tables of values consisting of information arranged in rows and columns. To identify a particular table element, we specify two indices—by convention, the first identifies the element’s row, the second the element’s column.
Lists that require two indices to identify an element are called two-dimensional lists (or double-indexed lists or double-subscripted lists ). Multidimensional lists can have more than two indices. Here, we introduce two-dimensional lists.
Creating a Two-Dimensional List
Consider a two-dimensional list with three rows and four columns (i.e., a 3-by-4 list) that might represent the ...
Get Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.