I have the following output from Python:
x1 = [[1, 1, 6, 12, 75, 75], [2, 2, 12, 36, 225, 300], [3, 3, 24, 84, 525, 825], [4, 4, 48, 180, 1125, 1950], [5, 5, 96, 372, 2325, 4275], [6, 6, 192, 756, 2835, 7110], [7, 7, 384, 1524, 5715, 12825], [8, 8, 768, 3060, 7650, 20475]]
x2 = [[1, 2, 6, 12, 75, 75], [2, 3, 12, 36, 225, 300], [3, 4, 24, 84, 525, 825], [4, 5, 48, 180, 1125, 1950], [5, 6, 96, 372, 2325, 4275], [6, 7, 192, 756, 2835, 7110]]
x3 = [[1, 3, 6, 12, 75, 75], [2, 4, 12, 36, 225, 300], [3, 5, 24, 84, 525, 825], [4, 6, 48, 180, 1125, 1950], [5, 7, 96, 372, 2325, 4275]]
x4 = [[1, 4, 6, 12, 75, 75], [2, 5, 12, 36, 225, 300], [3, 6, 24, 84, 525, 825], [4, 7, 48, 180, 1125, 1950]]
Basically I want to add these lists by matching up the second number in each (this second number represents a month, whereas the other numbers following it represent members or profit).
So if we look at lists x1 and x2, I would want to join x1[1] and x2[0] together because they both are equal at the second element (i.e. x1[1][1] and x2[0][1]).
By joining together I mean I would like to add them. Ideally I would prefer to only add the 3rd through 6 elements together.
You should check out using list comprehensions and slicing lists. That basically will let you turn:
into exactly what you want to do. To do the combining of lists, you might try creating a dict and them sum together at the end. I’m not 100% clear on what your expected output should be from that whole list and it’s somewhat dependent on other things going on in your code.