>>>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 OverflowHow do I get the shape of a Python list?
Why does a Python list have no shape attribute?
How do I convert a list to a NumPy shape?
>>>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.
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)