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
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-using-2d-arrays-lists-the-right-way
Using 2D arrays/lists in Python - GeeksforGeeks
This article focuses on correct ... 1D and 2D lists in Python. A 1D list stores elements in a linear sequence. Although Python does not have a native 1D array type, lists serve the same purpose efficiently. Manually initializing and populating a list without using any advanced features or constructs in Python is known as creating a 1D list using "Naive Methods". ... Explanation: [0] * N creates a list of size N. ... Explanation: range(N) controls list length...
Published   December 20, 2025
🌐
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
🌐
Bobby Hadz
bobbyhadz.com › blog › python-get-length-of-2d-array
How to get the length of a 2D Array in Python | bobbyhadz
Assuming that each nested list has the same number of elements, we can get the length of a column by accessing a nested list and passing the result to the len() function. You can get the total number of items in the 2D list by multiplying the ...
🌐
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
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)
🌐
Runestone Academy
runestone.academy › ns › books › published › csawesome › Unit8-2DArray › a2dSummary.html
8.3. 2D Arrays Summary — CSAwesome v1
For an array arr use arr.length to get the number of rows in the array. 2d Array Number of Columns - The number of columns (or width) is the length of the inner array.
Find elsewhere
🌐
Codedamn
codedamn.com › news › python
Python Array Size: How to Determine the Length
July 4, 2023 - The output will be 8 because the size of one double precision floating point type in Python is 8 bytes. When it comes to multidimensional arrays, determining the length might seem a bit tricky initially.
🌐
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 - This 2D array contains two (2) ... 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....
🌐
W3Schools
w3schools.com › python › gloss_python_array_length.asp
Python Array Length
Python Examples Python Compiler ... Q&A Python Bootcamp Python Certificate Python Training ... Use the len() method to return the length of an array (the number of elements in an array)....
🌐
IONOS
ionos.com › digital guide › websites › web development › python array length
How to find out the length of a Python array
July 11, 2023 - To find out the number of elements in your array, you can use the native Python len function. In the following example, we’ll create an array that contains the numbers 0 to 5. Using len ensures that the length of our Python array will be assigned ...
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-get-length-of-2d-array
How to Get the Length of 2D Array in Python | Tutorial Reference
This guide explores various techniques for getting the dimensions and total number of elements in 2D arrays in Python, covering both standard Python lists (lists of lists) and NumPy arrays.
🌐
Javatpoint
javatpoint.com › python-2d-array
Python 2D array - Javatpoint
Python 2D array with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
Scaler
scaler.com › home › topics › 2d array in python
2D Array in Python | Python Two-Dimensional Array - Scaler Topics
October 10, 2025 - 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, and thus it also represents a matrix. By linear data structure, we mean that the elements are linearly placed in memory, and each element is connected to its previous and next elements. We visualize a 2D array in a tabular format, but actually, elements are stored linearly in memory. Elements of a 2D array are contiguously placed in the memory.
🌐
GitHub
github.com › bobbyhadz › python-get-length-of-2d-array › blob › main › main.py
python-get-length-of-2d-array/main.py at main · bobbyhadz/python-get-length-of-2d-array
A repository for an article at https://bobbyhadz.com/blog/python-get-length-of-2d-array - bobbyhadz/python-get-length-of-2d-array
Author   bobbyhadz
🌐
Guru99
guru99.com › home › python › python 2d arrays: two-dimensional list examples
Python 2D Arrays: Two-Dimensional List Examples
August 12, 2024 - #creare 2D array with 4 rows and ... #display print(array) ... You can get the size of the two-dimensional array using the line() function....
🌐
Reddit
reddit.com › r/learnpython › multidimensional arrays?
r/learnpython on Reddit: Multidimensional arrays?
September 15, 2023 -

Hello!

I have 5 sets, each set contains a number of elements of variable length (eg. set 1 has 100 elements, set 2 has 150 and so on)

Is it possible to store these sets in a single structure?

For example, if I want to print the 35th elements of the 3rd set, I could call it simply by saying something like MyContainer[setN][elementN]

I was trying to use a 2D array but I can't initialize its shape, since each set has a variable number of elements.

Can anybody point me to the right direction / best practice?

Thank you