Given rectangular array (matrix) MxN with integer elements. M & N are the number of rows and columns of the rectangular matrix, received from input in one line separated by speces. Next, N lines with M numbers each, separated by a space – the elements of the matrix, integers, not exceeding 100 by absolute value.
For example:
Sample Input:
2 3
1 -2 3
4 5 6
Sample Output:
[[1, -2, 3], [4, 5, 6]]
Code:
cols, rows = [int(i) for i in input().split(" ")]
l = [[list(map(int, input()))] for j in range(rows)]
With rows its clear, however, I dont know how to control line length, so it be equal to the number, receved from input as cols
Any hints will be appreciated...