Hello

Is this a correct way of determining the rows and columns of a nxm matrix which is given as input ?

Thanks

Harish

mat_a = [

[1,0],

[0,1],

[2,3],

]

row = len(mat_a)

col = len(mat_a[0])

print(row,col)

Hello

Is this a correct way of determining the rows and columns of a nxm matrix which is given as input ?

Thanks

Harish

mat_a = [

[1,0],

[0,1],

[2,3],

]

row = len(mat_a)

col = len(mat_a[0])

print(row,col)

@hari.yajurveda,

This is fine, you might want to add a check that the number of elements in each row is the same. It is not necessary, but good to have, only because the matrix you gave is based on `list`

and not a numpy array.

2 Likes

Thank you. I just learnt about â€śListsâ€ť today and not aware of numpy and hence my question was based on that

Great ! All the best !