Generating variants over a list in Python
<p>Let me have a arbitrary list of positive integers:</p>

<pre><code>[2, 2, 3, 5]
</code></pre>

<p>I need to write a code, which will generate me a list of all products of those integers, enumerated like that:</p>

<pre><code>1111, ..., 1115, 1121, ..., 1125, ... 1135, 1235, 2235.
</code></pre>

<p>How do I do that?</p>

<pre><code>import itertools
itertools.product(range(1,3), range(1,3), range(1,4), range(1,6))
</code></pre>

<p>Docs here: <a href="https://docs.python.org/3/library/itertools.html#itertools.product" rel="nofollow">https://docs.python.org/3/library/itertools.html#itertools.product</a></p>

<p>A more general solution:</p>

<pre><code>itertools.product(*[range(1, n+1) for n in list_nums])
</code></pre>

python