This is called the "shape" in NumPy, and can be requested via the .shape attribute:

>>> a = zeros((2, 5))
>>> a.shape
(2, 5)

If you prefer a function, you could also use numpy.shape(a).

Answer from Sven Marnach on Stack Overflow
🌐
W3Schools
w3schools.com › python › gloss_python_array_length.asp
Python Array Length
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... Use the len() method to return the length of an array ...
Discussions

Creating an array who size and values depend on another array's values being put through a function
Since you mention arrays and arange, I presume you're using Numpy. The way to create one array by applying a function to each element from another array is by using vectorize . More on reddit.com
🌐 r/learnpython
6
18
May 21, 2022
Array length
It's ordered that way because that's the nature of a linked list. Usually, each element of a linked list consists of more than just the pointer to the next element in the list. You'll usually see linked lists used when new elements might be picked up or dropped from a list at any time, there is a need to be able to traverse the list, insertion or deletion is "expensive" (e.g., time-consuming), and the items being stored don't need to be stored in order in one big chunk of memory. It's just faster to include a pointer to the next element as part of the structure than to shuffle everything around whenever an insertion or deletion is needed. I suspect that this linked list consists of nothing but that pointer so that you can learn the nature of linked lists without being distracted by any additional overhead in each element in the list that you don't need to consider. Did that answer your question, or do you still have questions? More on reddit.com
🌐 r/learnpython
4
1
November 16, 2022
Why is getting the length of an array O(1) and not O(n)?
Most implementations store the length of an array in the object itself. Whenever you insert/remove it gets updated. Thus you're not iterating to get the length you're just getting a value. More on reddit.com
🌐 r/learnprogramming
45
11
November 7, 2022
What's the Python equivalent to this pseudo code for Array doubling in Data Structures?
Python is a high level programming language. While it’s possible to use libraries to get something resembling a C-style array, the Python programming language provides the list data-type which is an abstraction over an array that allows you to put arbitrary objects in it (it’s not restricted to a single type), and expand and reduce it dynamically (it handles memory allocation and de-allocation under the hood). The techniques you’re learning about at the moment are useful for understanding how programming works at a low level, but the whole point of a language like Python is that most of those techniques have been implemented for you (generally in quite optimised forms) in data structures that are easier and more pleasant to use while still being reasonably performant. Array doubling is useful because it provides amortised-constant runtime and linear memory usage when you’re wanting to expand a fixed-size array in individual steps, but that’s also what the append method does in Python’s list type. Of course for learning purposes you can just pretend that method doesn’t exist and implement its equivalent with your own code, it’s just good to be aware that when you’re programming in Python that kind of Han handling will generally be handled for you, and you’ll be operating at a more abstract level where you instead focus more on the actual ideas you’re trying to implement. Note that the understanding you’re gaining is valuable though. If you end up working with numerics (e.g. for data analysis or signal processing) then Python’s lists can be inefficient, in which case you’ll likely end up using arrays from the numpy library or DataFrames from the pandas or polars libraries. In those cases the expectation is to know how much data you have in advance, so appending is a linear-time operation that copies all the data to a slightly larger array every time, and is not recommended. More on reddit.com
🌐 r/learnpython
10
1
August 10, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-array-length
Python Array length - GeeksforGeeks
July 23, 2025 - Finding the length of an array in Python means determining how many elements are present in the array. For example, given an array like [1, 2, 3, 4, 5], you might want to calculate the length, which is 5.
🌐
CodeGym
codegym.cc › java blog › learning python › length of an array in python
Length of an Array in Python
November 7, 2024 - The simplest way to find the length of an array (or list) in Python is by using the len() function. This function is a built-in feature in Python and works on various data structures including lists, strings, and dictionaries.
🌐
Scaler
scaler.com › home › topics › length of array in python
Length of array in Python - Scaler Topics
May 25, 2022 - Essentially, the length of an array is the highest index position + 1. ... Python has a len() method to find out the length of an array.
🌐
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 ...
🌐
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 - To use arrays, you need to import other libraries first. In­te­grat­ing NumPy into your project will allow you to use Python arrays. To find out the number of elements in your array, you can use the native Python len function.
Find elsewhere
🌐
Java2Blog
java2blog.com › home › python › python array › python array size: get size of array in python
Python array size: get size of array in Python - Java2Blog
December 17, 2021 - In this article, we discussed several ways to get the size of array in Python. The most simple method is using the len() function, but it has its drawbacks and does not work with multidimensional arrays.
🌐
Udacity
udacity.com › blog › 2021 › 10 › how-to-calculate-the-length-of-an-array-in-python.html
How to calculate the length of an array in Python? | Udacity
October 20, 2021 - NumPy is unique in allowing you to capture multi-dimensional arrays. Calling size() on a multi-dimensional array will print out the length of each dimension.
🌐
Python
docs.python.org › 3 › library › array.html
array — Efficient arrays of numeric values
This change doesn’t affect its ... since Python 3.3. Deprecated since version 3.3, will be removed in version 3.16: Please migrate to 'w' typecode. Added in version 3.13. ... The ctypes and struct modules, as well as third-party modules like numpy, use similar – but slightly different – type codes. The actual representation of values is determined by the machine architecture (strictly speaking, by the C implementation). The actual size can be accessed through the array.itemsize ...
🌐
Leapcell
leapcell.io › blog › understanding-array-length-in-python
Understanding Array Length in Python | Leapcell
July 25, 2025 - Here, len(np_array) returns the size of the first dimension (i.e., the number of rows), while .size gives the total number of elements in the entire array. The .shape attribute provides the dimensions of the array. Understanding how to determine the length of an array in Python depends on the type of data structure you're working with.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.ndarray.size.html
numpy.ndarray.size — NumPy v2.5 Manual
Equal to np.prod(a.shape), i.e., the product of the array’s dimensions. ... a.size returns a standard arbitrary precision Python integer.
🌐
Codedamn
codedamn.com › news › python › array-size-determine-length-python
Python Array Size: How to Determine the Length
July 4, 2023 - The ed-tech landscape has transformed with the rise of AI. The tools developers use, the way they learn, and the skills that matter are all shifting rapidly. Rather than retrofitting Codedamn to keep pace, our team has chosen to focus our efforts on Fermion, our white-label LMS platform built on the technology behind Codedamn.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.ndarray.size.html
numpy.ndarray.size — NumPy v2.2 Manual
Equal to np.prod(a.shape), i.e., the product of the array’s dimensions. ... a.size returns a standard arbitrary precision Python integer.
🌐
TutorialsPoint
tutorialspoint.com › article › find-the-size-of-numpy-array
Find the size of numpy Array
March 27, 2026 - Integer array (int32): Elements: 5 Total memory: 20 bytes Bytes per element: 4 Float array (float64): Elements: 5 Total memory: 40 bytes Bytes per element: 8 String array (U1): Elements: 4 Total memory: 16 bytes Bytes per element: 4 · Use ...
🌐
FavTutor
favtutor.com › blogs › find-length-of-array-python
How to Find Length of an Array in Python? (5 Best Methods)
September 19, 2022 - Numpy also has a 'shape' attribute that can be used to determine the size of an array. Rather than returning the total number of elements in an array, this attribute returns a tuple containing the array's rows and columns, in the form (rows, ...
🌐
PyTutorial
pytutorial.com › python-array-size-how-to-find-and-manage-it
PyTutorial | Python Array Size: How to Find and Manage It
March 25, 2026 - Understanding .shape was key here. It told us we had 100 samples and 5 features. This allowed correct calculation of column averages. Finding array size in Python is a fundamental skill. For lists, use len().
🌐
iO Flood
ioflood.com › blog › get-length-of-array-in-python-guide-and-examples
Get Length of Array in Python: Guide and Examples
March 12, 2024 - The simplest way to determine the length of an array in Python is by using the built-in len() function. Simply pass the array as an argument to the function like so: length = len(array).
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.ndarray.size.html
numpy.ndarray.size — NumPy v2.1 Manual
Equal to np.prod(a.shape), i.e., the product of the array’s dimensions. ... a.size returns a standard arbitrary precision Python integer.
🌐
AskPython
askpython.com › python › array › array-length-in-python
How to Find the Array Length in Python - AskPython
April 3, 2023 - Python len() method is used to find the length of an array. As we all know, python does not support or provide us with the array data structure in a direct