The preferred way to get the length of any python object is to pass it as an argument to the len function. Internally, ... In case you want the dimensions of a 2D array you could use arr.shape returns height and width share | improve this answer answered