How can I get a list shape without using numpy?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How can I get a list shape without using numpy in Python. So Here I am Explain to you all the possible Methods here.

How can I get a list shape without using numpy?

1. How can I get a list shape without using numpy?

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

2. I get a list shape without using numpy

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

Method 1

>>>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)
>>>nrow
2
>>>ncol
3

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

Method 2

The question clearly states ‘without using numpy’. However, if anybody reached here looking for a solution without any condition, consider below. This solution will work for a balanced list.

b1=[[1,2,3], [4,5,6]]
np.asarray(b1).shape

(2, 3)

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.