(Apr-09-2020, 03:19 AM)michael1789 Wrote: You aren't appending, you are redefining things.They insert the list always in position 0. Technically not appending, you are right, but that is not the cause of the problem. Even if they append, the problem will persist.
what you want it is
megalist.append(list_of_three)This will tack it onto the end.
@teachinggeek: Lists are mutable object. Basically you insert the same object over and over again. Changes that you make affect also elements already inserted in the final list. That said, it's better to look at itertools.combinations()
>>> import itertools >>> numbers=[1, 3, 5, 7, 9, 11, 13, 15] >>> list(itertools.combinations(numbers, 3)) [(1, 3, 5), (1, 3, 7), (1, 3, 9), (1, 3, 11), (1, 3, 13), (1, 3, 15), (1, 5, 7), (1, 5, 9), (1, 5, 11), (1, 5, 13), (1, 5, 15), (1, 7, 9), (1, 7, 11), (1, 7, 13), (1, 7, 15), (1, 9, 11), (1, 9, 13), (1, 9, 15), (1, 11, 13), (1, 11, 15), (1, 13, 15), (3, 5, 7), (3, 5, 9), (3, 5, 11), (3, 5, 13), (3, 5, 15), (3, 7, 9), (3, 7, 11), (3, 7, 13), (3, 7, 15), (3, 9, 11), (3, 9, 13), (3, 9, 15), (3, 11, 13), (3, 11, 15), (3, 13, 15), (5, 7, 9), (5, 7, 11), (5, 7, 13), (5, 7, 15), (5, 9, 11), (5, 9, 13), (5, 9, 15), (5, 11, 13), (5, 11, 15), (5, 13, 15), (7, 9, 11), (7, 9, 13), (7, 9, 15), (7, 11, 13), (7, 11, 15), (7, 13, 15), (9, 11, 13), (9, 11, 15), (9, 13, 15), (11, 13, 15)]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs