Dictionary Combinations - Unequal Number of Keys & Values
<p>I want to print all unique combinations of keys and values for this dictionary:</p>

<pre><code>items = {'a':[10,100,1000],'b':[11,110],'c':[12,120]}
</code></pre>

<p>Using the code,</p>

<pre><code>for key, value in items.items():
    print(key,value)
</code></pre>

<p>I receive the following output:</p>

<pre><code>b [11, 110]
c [12, 120]
a [10, 100, 1000]
</code></pre>

<p>I would like to produce the following result given the dictionary:</p>

<pre><code>b 11
b 110
c 12
c 120
a 10
a 100
a 1000
</code></pre>

<p>Order of the key-value combinations is not important, but the result should preserve the relationship.  As always, any recommended resources and/or search terms associated with this problem will be appreciated.</p>

<p>You were really close:</p>

<pre><code>items = {'a':[10,100,1000],'b':[11,110],'c':[12,120]}

# iterate on key/items couple
for k,vl in items.items():
    # iterate on all values of the list
    for v in vl:
        # print with a simple format
        print("{} {}".format(k,v))
</code></pre>

<p>output:</p>

<pre><code>a 10
a 100
a 1000
c 12
c 120
b 11
b 110
</code></pre>

<p>Note that you can use <code>for k,vl in sorted(items.items()):</code> to print the keys in the sorted order <code>(a,b,c)</code>, same goes for the inside list:</p>

<pre><code># iterate on key/items couple
for k,vl in sorted(items.items()):
    # iterate on all values of the list
    for v in sorted(vl):
        # print with a simple format
        print("{} {}".format(k,v))
</code></pre>

<p>output:</p>

<pre><code>a 10
a 100
a 1000
b 11
b 110
c 12
c 120
</code></pre>

python loops dictionary