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>

<p>Is what you want something along these lines?</p>

<pre><code>&gt;&gt;&gt; data=[['nature', 'author1', 'author2', 'author3'],['sport', 'author1', 'author2', 'author3'],['Horses', 'author1', 'author2']]
&gt;&gt;&gt; for i in range(len(data)):
        for x in range(1, len(data[i])):
            print data[i][0], data[i][x] 
nature author1
nature author2
nature author3
sport author1
sport author2
sport author3
Horses author1
Horses author2
</code></pre>

python django for-loop