>>>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
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-shape-method
Python shape() method - All you need to know! | DigitalOcean
August 4, 2022 - Yes, it returns a tuple value that indicates the dimensions of a Python object. To understand the output, the tuple returned by the shape() method is the actual number of elements that represent the value of the dimension of the object.
๐ŸŒ
TechBeamers
techbeamers.com โ€บ get-list-shape-in-python
How to Find the List Shape in Python - TechBeamers
November 30, 2025 - For one-dimensional lists, the shape is simply the number of elements, while for multi-dimensional lists, it includes the size of each dimension. Imagine a list as a shopping cart where you can store various items.
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ how to get shape of list in python
How to Get Shape of List in Python - Spark By {Examples}
May 31, 2024 - How to get a shape of a list in Python? A list in Python doesn't have a specific shape or size, as it can be dynamically changed by adding or removing
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ get shape from list
r/learnpython on Reddit: Get shape from list
April 13, 2024 -

Hello, I am making an area calculator which allows you to calculate the areas of different shapes, and I'm new to python.

The problem I am having here is that I need to access them from a list, by typing in the index no. as opposed to typing the name of the shape,

for example, i might need to access them using thier index values. if this is possible, how can i do so?

here is the code: Area Calculator

๐ŸŒ
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.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ get list shape in python
How to Get List Shape in Python | Delft Stack
February 2, 2024 - It returns a tuple that contains the number of elements in each dimension of an array. The NumPy package was originally designed to be used with arrays but could also work with lists.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_shape.asp
NumPy Array Shape
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS
Find elsewhere
๐ŸŒ
Python Pool
pythonpool.com โ€บ home โ€บ blog โ€บ how to get shape of a list in python
How To Get Shape of a List in Python - Python Pool
August 28, 2021 - We can calculate a shape of a list using two methods, len() and NumPy array shape. Numpy has an attribute named np.shape to get the shape of a list or tuple. We can also calculate a shape for the nested list.
๐ŸŒ
sebhastian
sebhastian.com โ€บ list-shape-python
How to get the shape of a list or tuple in Python | sebhastian
May 10, 2023 - In Python, lists and tuples are collection objects that can contain multiple values. Sometimes, you need to get the number of elements contained in these objects. When using the NumPy library, you can find the shape of an array using the .shape property:
๐ŸŒ
OpenSourceOptions
opensourceoptions.com โ€บ how-to-find-the-shape-of-a-python-tuple-or-list
How to Find the Shape of a Python Tuple or List โ€“ OpenSourceOptions
Python tuples and lists are fundamentally different from arrays because they do not have a set number of rows and columns. In other words, a tuple (or list) can have any number of elements at any position. This is shown by the tuple above, which has a length of 3. However, the tuples within `my_tuple_2dโ€™ each have different shapes of 3, 2, and 4, respectively.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ numpy โ€บ methods โ€บ shape
NumPy shape()
Become a certified Python programmer. Try Programiz PRO! ... The shape() method returns the shape of an array i.e.
๐ŸŒ
AI Planet
aiplanet.com โ€บ learn โ€บ introduction-to-numpy โ€บ basic-methods-on-array-and-reshaping โ€บ 94 โ€บ reshaping-an-array
Reshaping an Array | AI Planet (formerly DPhi)
Using np.reshape() you can change the shape of a Python list but the returned object is of type numpy.ndarray, i.e., it becomes a NumPy array.
๐ŸŒ
OpenSourceOptions
opensourceoptions.com โ€บ how-to-find-the-shape-of-a-nested-list-or-tuple-in-python
How to Find the Shape of a Nested List or Tuple in Python โ€“ OpenSourceOptions
April 7, 2021 - To find the shape (or dimensions) of a nested list or tuple in Python, iterate over each element in the list or tuple and identify its length with the built-in len() function. This can become very complicated if the list or tuple has more than two dimensions.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.ndarray.shape.html
numpy.ndarray.shape โ€” NumPy v2.4 Manual
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 ...
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.2 โ€บ reference โ€บ generated โ€บ numpy.ndarray.shape.html
numpy.ndarray.shape โ€” NumPy v2.2 Manual
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 ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ numpy-array-shape
NumPy Array Shape - GeeksforGeeks
July 15, 2025 - 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.
๐ŸŒ
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 - Use reshape() to convert the shape. See the following article for details. ... 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 that returns the number of elements in a list or the number of characters in a string.