Function for Iteration over tuples
<p>I have the following problem:
I want to iterate over a given list and return the minimum of the sum of all possible cartesian products:</p>

<pre><code>from itertools import product

z = ((1, 2),(2, 3))

def zmin(tup):
    return min(sum(a*a for a in s) for s in product(tup))

zmin(z) --&gt; ERROR MESSAGE
</code></pre>

<p>The correct answer should be like that:</p>

<pre><code>1*1 + 2*2 =  5
1*1 + 3*3 = 10
2*2 + 2*2 =  8
2*2 + 3*3 = 13
</code></pre>

<p>So that the return value of zmin(z) = 5</p>

<p>Do you know what am i doing wrong?
Also is there an efficient way with bumpy or something similar?</p>

<p>I found an soloution myself:
I added <code>*args</code> for return value:</p>

<pre><code>def zmin(tup):
    return min(sum(a*a for a in s) for s in product(*tup))
</code></pre>

python tuples itertools