python matrix creation without using numpy or anything and max sum of rows and columns
<p>Want to create a matrix like below in python</p>

<pre><code>[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
</code></pre>

<p>but not sure how to do, i tried list comprehension like below</p>

<pre><code>[[y+x for y in range(4)] for x in range(4)]
</code></pre>

<p>which gives output like below</p>

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

<p>and also want print the row with maximum sum and columns with maximum sum.</p>

<p>Thanks in advance </p>

<p>try this,</p>

<pre><code>In [1]: [range(1,17)[n:n+4] for n in range(0, len(range(1,17)), 4)]
Out[1]: [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
</code></pre>

python matrix