Get all pairs from elements in sublists
<p>I have a list of sublists. I need all possible pairs between the elements in the sublists. For example, for a list like this: </p>

<pre><code>a=[[1,2,3],[4,5],[6]]
</code></pre>

<p>The result should be: </p>

<pre><code>result=[[1,4], [1,5], [1,6], 
        [2,4], [2,5], [2,6], 
        [3,4], [3,5], [3,6], 
        [4,6], [5,6]]
</code></pre>

<p>The lists (and sublists) are of various, random lengths. </p>

<pre><code># create an empty set to store unique sublist elements
initSet = set()

# combine all sublist elements
for sublist in a:
    tempSet = set(sublist)
    initSet = intiSet.union(tempSet)

initSet = list(initSet)
# find all possible non-repeating combinations
for _element in initSet:
    combinations = list()
    for i in range(1, len(initSet) - 1):
        combinations.append([_element, initSet[i]]
    initSet.pop(0)

#result stored in combinations
</code></pre>

python