Sep-11-2019, 06:53 AM
Going to explain in simple language since googling this didn't really help me (unsure how to name this problem).
I have a list which items I want to check with eachother. Each combination triggers a function.
So a list with [1,2,3] should run a function for pair [1,2], for pair [1,3] and for pair [2,3]. Duplicates / themselves aren't needed [1,1] [2,1] [2,2] [3,1] [3,2]
My list might become huge (600K (if that is huge)) so I 'Yield' seems interesting too.
Below is my soup. Horrible, not logical, returns duplicates (I know
).
I have a list which items I want to check with eachother. Each combination triggers a function.
So a list with [1,2,3] should run a function for pair [1,2], for pair [1,3] and for pair [2,3]. Duplicates / themselves aren't needed [1,1] [2,1] [2,2] [3,1] [3,2]
My list might become huge (600K (if that is huge)) so I 'Yield' seems interesting too.
Below is my soup. Horrible, not logical, returns duplicates (I know

listA = [1,2,3,4,5,6] listB = listA[:] output = [] for a in listA: for b in listB: if b != a: //function here output.append([a,b]) print(output)