print dimensions of array python code example
Example 1: code for dimensions in numpy
import numpy as np
arr = np.array([1, 2, 3, 4])
arr_2D = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
print(arr.ndim)
print(arr_2D.ndim)
Example 2: size array python
size = len(myList)
Example 3: size of matrix python
>>> a=[[1,5,6,8],[1,2,5,9],[7,5,6,2]]
>>> len(a)
3
>>> len(a[0])
4