Feb. 14, 2024, 8:22 p.m. | DHRUV TRIVEDI

DEV Community dev.to

In Python, a 2D array (or matrix) is essentially a list of lists. You can access elements, rows, and columns in a 2D array using indexing.


Here's how you can do it:


Accessing an element: To access an element in a 2D array, you use two indices. The first index is for the row and the second index is for the column. For example, matrix[i][j] will give you the element at the ith row and jth column.


Accessing a …

array element indexing list lists matrix programming python tutorial

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Consultant Senior Power BI & Azure - CDI - H/F

@ Talan | Lyon, France