def _rectangular ( n ) : for i in n : if len ( i ) != len ( n [ 0 ] ) : return False return True
check list dimension python
Checks to see if a 2D list is a valid 2D matrix
def _rectangular(n):
    """Checks to see if a 2D list is a valid 2D matrix"""
    for i in n:
        if len(i) != len(n[0]):
            return False
    return True