how to create a for loop for this case in python?
<p>maybe the title seems strange, but i'm bloqued for certain times searching how to create a for loop of this case:</p>

<p>I have a list of lists having this format :</p>

<pre><code> data=[['nature', author1, author2, ...author n]
       ['sport', author1, author2, ....author n]
       ....
      ]
</code></pre>

<p>I have tried this code :</p>

<pre><code>        authors=[author1, author2, ...author n]
         for i in range(len(authors)):

        data = [['nature', function(names[i], 'nature')],
                ['sport', function(names[i], 'sport')
             ..]
</code></pre>

<p>but unfortunately I guess it returns a result in this format :</p>

<pre><code> data=[['nature', author1]
       ['sport', author1]
       ....
      ]
</code></pre>

<pre><code>ary_grp_Example = [["AA1", "BB1"], ["CC2", "DD2"],["EE3","FF3"]] ### Dimension as a three column matrix array (list)
ary_grp_Example.pop(0)  ## Kill the first record leaving two

#Loop through by row (x)
for int_CurCount in range(0,len(ary_grp_Example)): 
      print ("Row: " + str(int_CurCount) 
             + " was #" 
             + str(ary_grp_Example[int_CurCount][0]) 
             + "#" + str(ary_grp_Example[int_CurCount][1]) 
             +"#")

#Loop through by Cell (x,y) 
for int_RowCount in range(0,len(ary_grp_Example)): 
   for int_ColCount in range(0,len(ary_grp_Example[int_RowCount]) ):
      print ("Cell Data for location =(" 
             + str(int_RowCount) + "," 
             + str(int_ColCount) +  ") was #" 
             + ary_grp_Example[int_RowCount][int_ColCount] 
             + "#")  
</code></pre>

<p>You can get to the data if you use two numbers data[1][1] or data[1][2].  Sometimes referred to as a matrix array or matrix list.  Pythons name for it appears to be a "list" but it is a multi dimensional list aka matrix array/list.</p>

<p>Sport Author 2 for example would be data[1][2] as these are zero based counting.</p>

<p>To loop through all the data you have to loop by row and by column like you would a database result set.</p>

python django for-loop