Lists aggregation

mattia gervaz at gmail.com
Mon Mar 16 14:07:06 EDT 2009


I have 2 lists, like:
l1 = [1,2,3]
l2 = [4,5]
now I want to obtain a this new list:
l = [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
Then I'll have to transform the values found in the new list.
Now, some ideas (apart from the double loop to aggregate each element of 
l1 with each element of l2):
- I wanted to use the zip function, but the new list will not aggregate 
(3,4) and (3,5)
- Once I've the new list, I'll apply a map function (e.g. the exp of the 
values) to speed up the process
Some help?

Thanks, Mattia



More information about the Python-list mailing list