What does a number mean before a for-loop
<p>I'm new to Python. Would greatly appreciate if you could explain how this line works. What does it mean to have a number before a for-loop?</p>

<pre><code>adjacency_matrix = [[0 for i in range(max_index + 1)] for j in range(max_index + 1)]
</code></pre>

<p>I know that </p>

<pre><code>max_index = 4
adjacency_matrix = [[0 for i in range(max_index + 1)] for j in range(max_index + 1)]
&gt;&gt;&gt;[[0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0]] 
</code></pre>

<p>But I don't understand how it works. </p>

<p>Thanks</p>

<p>If we use variable in list comprehension to populate a list, the resultant list takes the value of the variable whenever condition met. Since we are using '0' means list get populated by the value '0' whenever condition met.</p>

python list-comprehension