>>>a = [1,2,3,4,5,6]
>>>print (len(a))
6

For one dimensional lists, the above method can be used. len(list_name) returns number of elements in the list.

>>>a = [[1,2,3],[4,5,6]]
>>>nrow = len(a)
>>>ncol = len(a[0])
>>>nrow
2
>>>ncol
3

The above gives the dimension of the list. len(a) returns number of rows. len(a[0]) returns number of rows in a[0] which is the number of columns.

Here's a link to original answer.

Answer from arunppsg on Stack Overflow
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_shape.asp
NumPy Array Shape
NumPy arrays have an attribute called shape that returns a tuple with each index having the number of corresponding elements.
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-array-shape
NumPy Array Shape - GeeksforGeeks
July 15, 2025 - Dimension is the number of indices or subscripts, that we require in order to specify an individual element of an array. In NumPy, we will use an attribute called shape which returns a tuple, the elements of the tuple give the lengths of the corresponding array dimensions.
People also ask

How do I get the shape of a Python list?
Use len(values) for a one-dimensional list and inspect nested row lengths for a list of lists.
🌐
pythonpool.com
pythonpool.com › home › tutorials › list shape in python: rectangular, ragged, and numpy arrays
List Shape in Python: Rectangular, Ragged, and NumPy Arrays
Why does a Python list have no shape attribute?
shape is an array concept and ordinary lists only provide sequence operations; NumPy arrays expose shape metadata.
🌐
pythonpool.com
pythonpool.com › home › tutorials › list shape in python: rectangular, ragged, and numpy arrays
List Shape in Python: Rectangular, Ragged, and NumPy Arrays
How do I convert a list to a NumPy shape?
Validate that rows are rectangular, then call np.asarray(values) and inspect the resulting array.shape.
🌐
pythonpool.com
pythonpool.com › home › tutorials › list shape in python: rectangular, ragged, and numpy arrays
List Shape in Python: Rectangular, Ragged, and NumPy Arrays
🌐
TechBeamers
techbeamers.com › get-list-shape-in-python
How to Find the List Shape in Python - TechBeamers
November 30, 2025 - In this case, the list has 3 rows and 3 columns, so the shape will be (3, 3). If you’re working with multi-dimensional arrays or so to say a list, Python’s NumPy library provides a convenient way to get the shape.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.ndarray.shape.html
numpy.ndarray.shape — NumPy v2.5 Manual
Method similar to setting shape. ... Try it in your browser! >>> import numpy as np >>> x = np.array([1, 2, 3, 4]) >>> x.shape (4,) >>> y = np.zeros((2, 3, 4)) >>> y.shape (2, 3, 4)
🌐
Delft Stack
delftstack.com › home › howto › python › get list shape in python
How to Get List Shape in Python | Delft Stack
February 2, 2024 - The most straightforward approach to get the shape of a one-dimensional list in Python involves using the len() function. For nested lists, list comprehensions along with the len() function can help determine the number of rows and columns ...
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.ndarray.shape.html
numpy.ndarray.shape — NumPy v2.6.dev0 Manual
Method similar to setting shape. ... Try it in your browser! >>> import numpy as np >>> x = np.array([1, 2, 3, 4]) >>> x.shape (4,) >>> y = np.zeros((2, 3, 4)) >>> y.shape (2, 3, 4)
Find elsewhere
🌐
Python Pool
pythonpool.com › home › tutorials › list shape in python: rectangular, ragged, and numpy arrays
List Shape in Python: Rectangular, Ragged, and NumPy Arrays
July 13, 2026 - Quick answer: A plain Python list has no shape attribute. Use len(values) for a one-dimensional count, inspect every row for a nested list, and distinguish rectangular data from ragged data before calling NumPy.
🌐
Medium
medium.com › @surya.vijjeswarapu › understanding-lists-in-python-and-numpy-array-shapes-6f4f0c4d2972
Understanding Lists in Python and Numpy Array Shapes | by Vijjeswarapu Surya Teja | Medium
June 24, 2022 - Lists in python doesn’t have shape so we need to convert them into Numpy Arrays to understand the shape of our data in the list.
🌐
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 - NumPy: Add new dimensions to an array (np.newaxis, np.expand_dims) The shape of a NumPy array, i.e., the length of each dimension, is represented as a tuple and can be accessed using the shape attribute.
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.shape.html
numpy.shape — NumPy v2.6.dev0 Manual
>>> a = np.array([(1, 2), (3, 4), (5, 6)], ... dtype=[('x', 'i4'), ('y', 'i4')]) >>> np.shape(a) (3,) >>> a.shape (3,)
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.ndarray.shape.html
numpy.ndarray.shape — NumPy v2.2 Manual
Tuple of array dimensions. The shape property is usually used to get the current shape of an array, but may also be used to reshape the array in-place by assigning a tuple of array dimensions to it. As with numpy.reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of the array and the remaining dimensions.
🌐
Python Guides
pythonguides.com › python-numpy-shape
NumPy Shape And Array Dimensions In Python
May 8, 2025 - There is a separate np.shape function, and that one does take parentheses. It works on anything array-like, including lists, which makes it the safer choice in code that accepts either.
🌐
Medium
medium.com › @amit25173 › numpy-shape-in-python-6cfe7cb20084
numpy.shape in Python. If you think you need to spend $2,000… | by Amit Yadav | Medium
February 9, 2025 - Important Tip: The number of elements must match before and after reshaping. If you try to reshape an array with 6 elements into, say, a 3x3 matrix (which needs 9 elements), you’ll get an error. Try this for yourself to see how it works — it’s one of the most common operations you’ll use with shape.
🌐
Hyperskill
hyperskill.org › university › numpy › numpy-array-shape
NumPy Array Shape
September 4, 2024 - For instance, using np.array([[1, 2], [3, 4]]) creates a 2D array. The shape of the array refers to its dimensions, like the number of rows and columns. The np.array() function is used to create arrays in Python. By passing a list or tuple of values to the function, it converts them into an array.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-shape-method
Python shape() method - All you need to know! | DigitalOcean
August 4, 2022 - Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
Interactive Chaos
interactivechaos.com › en › python › function › ndarrayshape
ndarray.shape | Interactive Chaos
Python scenarios · Full name · ndarray.shape · Library · NumPy · Syntax · ndarray.shape · Description · The numpy.ndarray.shape attribute returns a tuple with the size of the array, but can also be used to resize it.