Python Multiplicative Array Concatenating
<p>If I have a array of an inconsistent size, <code>lists</code> that consists of an (inconsistent) amount of lists:</p>

<pre><code> lists = [List1, List2, List3,...ListN]
</code></pre>

<p>where each contained list is of inconsistent size.</p>

<p>How can I concatenate the contents multiplicatively of each contained array.</p>

<p><strong>Example of target output:</strong></p>

<pre><code>A = ["A","B","C","D"]
B = ["1","2","3","4"]
C = ["D","E","F","G"]
A[0-N] + B[0-N] + C[0-N]

Giving ["A1D","B1D","C1D","D1D",
        "A2D","B2D","C2D","D2D"
        "A3D","B3D","C3D","D3D"
        "A4D","B4D","C4D","D4D"
        "A1E","B1E","C1E","D1E"

         ... "C4G","D4G"  ]
</code></pre>

<p>For this specific example it should yield a list length of 4^3.
(List length to the power of the number of lists)</p>

<p>However list length is not constant so it is really </p>

<p><code>List1 Length * List2 Length * List3 Length * ... * ListN Length</code></p>

<p>For an inconsistent list length: </p>

<pre><code>  A = ["A","B"]
  B = ["1","2","3","4"]

 = ["A1","A2","A3","A4","B1","B2","B3","B4"]
</code></pre>

<p>I have tried python maps and zips, but I am having trouble doing for example:</p>

<pre><code>zip(list1, list2, list3)
</code></pre>

<p>when:</p>

<p>Amount of lists is not consistent</p>

<p>The lists are not stored separately but collated in one large list,</p>

<p>and the list size is not consistent</p>

<p>Methods described on other SO Question only address consistent size, 2 list, situations. I am having trouble applying these techniques in this situation.</p>

<pre><code>import itertools
A = ["A","B"]
B = ["1","2","3","4"]
list(itertools.product(A, B))
</code></pre>

<p>Generic</p>

<pre><code>lists_var = [List1, List2, List3,...ListN]
list(itertools.product(*lists_var))
</code></pre>

python arrays list