On 2007-01-08, cesco <[EMAIL PROTECTED]> wrote: > Hi, > > I have a dictionary of lists of tuples like in the following example: > dict = {1: [(3, 4), (5, 8)], > 2: [(5, 4), (21, 3), (19, 2)], > 3: [(16, 1), (0, 2), (1, 2), (3, 4)]] > > In this case I have three lists inside the dict but this number > is known only at runtime. I have to write a function that > considers all the possible combinations of tuples belonging to > the different lists and return a list of tuples of tuples for > which the sum of the first element of the most inner tuple is > equal to N. > > For example, assuming N = 24, in this case it should return: > [((3, 4), (5, 4), (16, 1)), ((3, 4), (21, 3), (0, 2)), ((5, 8), (19, > 2), (0, 2))]
What do you mean by "most inner tuple"? > A simple list comprehension would be enough if only I knew the > number of keys/lists beforehand len(dict.keys()). -- Neil Cerutti Next Sunday Mrs. Vinson will be soloist for the morning service. The pastor will then speak on "It's a Terrible Experience." --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list