Sakhri Houssem
Sakhri Houssem

Reputation: 1063

How can I get the number of columns and rows from 2D list

I create a 2D List with n cols and m rows:

2DList = [[0 for x in range(cols)] for y in range(rows)]

How can I get the number of cols and rows with the simple method?

Upvotes: 4

Views: 8537

Answers (1)

Abhijith Asokan
Abhijith Asokan

Reputation: 1875

No.of rows = len(matrix)

No.of cols = len(matrix[0]), if all the rows are of same size

Upvotes: 9

Related Questions