Combining arbitrary lists

Nick nchackowsky at gmail.com
Sun Nov 14 23:18:46 EST 2004


Mariano Draghi wrote:
> Nick wrote:
> 
>> Given that
>>
>> n = [ [1, 2, 3], [4, 5, 6], [7, 8] ]
>>
>> then the following code produces what I expect
>>
>> for x in n[0]:
>>   for y in n[1]:
>>     for z in n[2]:
>>       print [x, y, z]
> 
> 
> ...
> 
>>
>> How can I do this for an arbirary length of n?
> 
> 
> I think this is what you're looking for:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302478
> 
>> Muchos Gracias
> 
> 
> De nada ;)
> 
Okay... a) THANK-YOU, and b) HOW did you find that?

Nick.



More information about the Python-list mailing list