I have a list with nested lists of different lengths ranging from 3 to 105. I want to create based on that new lists that contain a combination of all pairs in these original list following the format: from [7,5,6] to [7,5], [7,6], [5,6]
I used the code below, but this is not feasible with 105 values in a list. Is there an algorithm that can automate this process?
list3 = ([7,5,6], [6,9,7], [7,8,4], [2,4,6,7,9])
list4 = []
for sublist in list3:
if len(sublist) == 3:
list4.append([sublist[0], sublist[1])
list4.append([sublist[0], sublist[2])
list4.append([sublist[1], sublist[2])