title: Printing combinations of two lists in Python
body: <p>What I'm trying to print is the following, using 2 variables in each string for simplicity. I think something's wrong using the loops, i'm kinda new to Python. Thanks in advance!</p>
  <pre><code>com0 &lt;-(a) with (1,)
  com1 &lt;-(a) with (2,)
  com2 &lt;-(a) with (1, 2)
  com3 &lt;-(b) with (1,)
  com4 &lt;-(b) with (2,)
  com5 &lt;-(b) with (1, 2)
  com6 &lt;-(a,b) with (1,)
  com7 &lt;-(a,b) with (2,)
  com8 &lt;-(a,b) with (1, 2)
  </code></pre>
  <p>This is what I've tried:</p>
  <pre><code>import itertools
  
  i = 0 #v1
  j = 0 #v2
  
  v1 = [1, 2]
  v2 = [&quot;a&quot;,&quot;b&quot;]
  
  while j &lt; 2**len(v2):
  
      for K in range(0, len(v2)+1):
  
          while i &lt; 2**len(v1):
  
              for L in range(0, len(v1)+1):
  
                  for subset2 in itertools.combinations(v1, L):
  
                      for subset1 in itertools.combinations(v2, K):
  
                          print(&quot;com{0} &lt;-{1} with {2}&quot;.format(i,subset1,subset2))
  
                          i+=1
                          j+=1
  </code></pre>