Like this:

numrows = len(input)    # 3 rows in your example
numcols = len(input[0]) # 2 columns in your example

Assuming that all the sublists have the same length (that is, it's not a jagged array).

Answer from Óscar López on Stack Overflow
🌐
Bobby Hadz
bobbyhadz.com › blog › python-get-length-of-2d-array
How to get the length of a 2D Array in Python | bobbyhadz
April 8, 2024 - The size attribute returns the number of elements in the NumPy array. ... Copied!import numpy as np my_2d_arr = np.array([[1, 2, 3], [4, 5, 6]]) print(my_2d_arr.size) # 👉️ 6 print(my_2d_arr.shape) # 👉️ (2, 3)
Discussions

Find length of 2D array Python - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
February 28, 2020
Find length of 2D array Python - Stack Overflow
How do I find how many rows and columns are in a 2d array? More on stackoverflow.com
🌐 stackoverflow.com
I want to know the length of a two-dimensional array
Assuming that every row has the same amount of elements you can get the length of the array with len(array) to get the amount of rows, and then get the number of columns by checking the length of the first row len(array[0]). Example array = [[1, 2, 3],[1, 2, 3]] print(len(array), len(array[0]) # outputs 2, the number of rows, and 3, the number of columns More on reddit.com
🌐 r/AskProgramming
6
0
December 24, 2021
2 D Arrays in Python

Pay attention to what for y in x does. It doesn't give you array indices, instead it gives you actual elements.

More on reddit.com
🌐 r/learnprogramming
4
0
July 19, 2018
🌐
AskPython
askpython.com › python › two-dimensional-array-in-python
Two Dimensional Array in Python - AskPython
December 27, 2019 - Output-2D Array · Input to a 2-D array is provided in the form of rows and columns. Example: size = int(input()) array_input = [] for x in range(size): array_input.append([int(y) for y in input().split()]) print(array_input) Output: Output-Input 2D Array · Elements in a 2D array can be inserted using the insert() function specifying the index/position of the element to be inserted.
🌐
sebhastian
sebhastian.com › python-2d-array-length
How to find the length of 2D array in Python | sebhastian
February 17, 2023 - To find the length of a 2D array, you need to find the total number of items stored in that array with the len() function.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Get the dimensions, shape, and size of an array | note.nkmk.me
April 23, 2025 - You can get the size, i.e., the total number of elements, of a NumPy array with the size attribute. ... print(a_1d.size) # 3 print(type(a_1d.size)) # <class 'int'> print(a_2d.size) # 12 print(a_3d.size) # 24 ... len() is a built-in Python function ...
🌐
Guru99
guru99.com › home › python › python 2d arrays: two-dimensional list examples
Python 2D Arrays: Two-Dimensional List Examples
October 7, 2026 - 📏 How do you find the number of rows and columns in a 2D array? Use len(array) for the number of rows and len(array[0]) for the columns in the first row. With NumPy, the shape attribute returns both values as a (rows, columns) tuple.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-size-function-python
Numpy size() function | Python - GeeksforGeeks
July 12, 2025 - The numpy.size() function is a tool to understand how many elements exist in your array whether it's one-dimensional or multi-dimensional.
🌐
Finxter
blog.finxter.com › home › learn python blog › how to get the length of a 2d numpy array
How to Get the Length of a 2D NumPy Array - Be on the Right Side of Change
October 17, 2022 - The next line calls shape() and passes the 2D array, two_dims, as an argument. The results save to tot_tuple (a Tuple) and are output to the terminal. To retrieve the length, we multiply the Tuple (2*5) and output the results to the terminal. This example uses size from the NumPy library to determine the length of a 2D array.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-using-2d-arrays-lists-the-right-way
Using 2D arrays/lists in Python - GeeksforGeeks
The code below, compares two ways of initializing a 2D list in Python. Using list multiplication ([[0]*cols]*rows) creates multiple references to the same inner list, causing aliasing where changes affect all rows. Using a nested list comprehension creates a separate list for each row, avoiding aliasing and correctly forming a 2D array.
Published: December 20, 2025
🌐
Note.nkmk.me
note.nkmk.me › home › python
Get the Size (Length, Number of Items) of a List in Python | note.nkmk.me
August 24, 2023 - If NumPy is installed in your environment, you can convert a list of lists to a NumPy array (numpy.ndarray). You can get the total number of items with the size attribute, and the shape (number of rows and columns) with the shape attribute. ... import numpy as np l_2d = [[0, 1, 2], [3, 4, 5]] arr_2d = np.array(l_2d) print(arr_2d) # [[0 1 2] # [3 4 5]] print(arr_2d.size) # 6 print(arr_2d.shape) # (2, 3)
🌐
Scaler
scaler.com › home › topics › 2d array in python
2D Array in Python | Python Two-Dimensional Array - Scaler Topics
May 25, 2026 - A 2D array in python is a two-dimensional data structure stored linearly in the memory. It means that it has two dimensions, the rows and the columns, so it can be visualized like a table and thus it also represents a matrix.
🌐
Snakify
snakify.org › two-dimensional lists (arrays)
Two-dimensional lists (arrays) - Learn Python 3 - Snakify
Suppose that two numbers are given: the number of rows of n and the number of columns m. You must create a list of size n×m, filled with, say, zeros.
🌐
IONOS
ionos.com › digital guide › websites › web development › python array length
How to find out the length of a Python array - IONOS
July 11, 2023 - If you work with arrays in Python and want to find out their length, you have several options to choose from. Here, we’ll explain how to use the Python functions len and size.
🌐
Google
sites.google.com › rgc.aberdeen.sch.uk › rgcahcomputingrevision › software-design › data-types-and-structures › 2d-arrays
Advanced Higher Computing Revision - 2D Arrays
And the the number of elements can be accessed by using the length predefined function (Python). A 1D array is where you specified the number elements (columns) in an array – it has one dimension. When declaring a 2 dimensional (2D) array we specify the rows and columns
🌐
Javatpoint
javatpoint.com › python-2d-array
Python 2D array - Javatpoint
January 10, 2021 - Python 2D array with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
Quora
quora.com › How-do-I-find-the-length-of-two-dimensional-arrays
How to find the length of two dimensional arrays - Quora
Answer: array= ([[1, 2], [3, 4], [5, 6]]) numrows = len(array) # 3 rows in your example numcols = len(array[0]) # 2 columns in your example print(numrows) print(numcols) reference: Find length of 2D array Python
🌐
NumPy
numpy.org › doc › stable › reference › arrays.ndarray.html
The N-dimensional array (ndarray) — NumPy v2.5 Manual
That is, an ndarray can be a “view” ... objects implementing the memoryview or array interfaces. ... Try it in your browser! A 2-dimensional array of size 2 x 3, composed of 4-byte integer elements:...