How to build python matrix (multidimensional array) based on number of rows and colums received from input
<p>Given rectangular array (matrix) MxN with integer elements. M &amp; 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.</p>

<p>For example:</p>

<p>Sample Input:</p>

<pre><code>2 3
1 -2 3
4 5 6
</code></pre>

<p>Sample Output:</p>

<pre><code>[[1, -2, 3], [4, 5, 6]]
</code></pre>

<p>Code:</p>

<pre><code>cols, rows = [int(i) for i in input().split(" ")] 

l = [[list(map(int, input()))] for j in range(rows)]
</code></pre>

<p>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 </p>

<p>Any hints will be appreciated...</p>

<p>First of all based on sample output, I saw that rows and cols should be  interchanged and second use split by cols [:cols] as shown in the code below</p>

<pre><code>rows, cols = [int(i) for i in input().split(" ")]
l = [map(int, input().split(" ")[:cols]) for i in range(rows)]
</code></pre>

python arrays python-3.x matrix input