In addition, correct way to count total item number would be:
sum(len(x) for x in input)
Assuming input[row][col],
rows = len(input)
cols = map(len, input) #list of column lengths
assuming input[row][col]
rows = len(input)
cols = len(list(zip(*input)))
You can use numpy.shape
.
import numpy as np
x = np.array([[1, 2],[3, 4],[5, 6]])
Result:
>>> x
array([[1, 2],
[3, 4],
[5, 6]])
>>> np.shape(x)
(3, 2)
First value in the tuple is number rows = 3; second value in the tuple is number of columns = 2.
You can also use np.size(a,1), 1 here is the axis and this will give you the number of columns
Source: Stackoverflow.com