Split sublist of a list into other sublists
<p>I am having problems with 'splitting' a larger list into several of it's combinations. Here is an example:</p>

<p>Let's say I have this list:</p>

<pre><code>  x = [['a','b'],['c','f'],['q','w','t']]
</code></pre>

<p>and I want to end up with</p>

<pre><code>  x = [['a','b'],['c','f'],['q','w'],['q','t'],['w','t']]
</code></pre>

<p>so essentially</p>

<pre><code> ['q','w','t']
</code></pre>

<p>becomes</p>

<pre><code> ['q','w'],['q','t'],['w','t']
</code></pre>

<p>I see how I can convert</p>

<pre><code> ['q','w','t']
</code></pre>

<p>to</p>

<pre><code> [['q','w'],['q','t'],['w','t']] #notice the extra brackets
</code></pre>

<p>with itertools combinations, but then I am stuck with</p>

<pre><code> x = [['a','b'],['c','f'],[['q','w'],['q','t'],['w','t']]] #notice the extra brackets
</code></pre>

<p>Which is not what I want.</p>

<p>How should I do this?</p>

<p>EDIT:</p>

<p>Here is the "solution", that does not give me the result that I want:</p>

<pre><code>from itertools import combinations

x = [['a','b'],['c','f'],['q','w','t']]

new_x = []

for sublist in x:
    if len(sublist) == 2:
        new_x.append(sublist)
    if len(sublist) &gt; 2:
        new_x.append([list(ele) for ele in (combinations(sublist,2))])
</code></pre>

<p>Thank You</p>
