Why does this Punnet square fail?
<p>This is part of my program for generating punnet squares. It should separate a "genome" of the form [['A','a'],['b','b'],['C',C']...] into possible gametes:</p>

<pre><code>def gene_erator2(gen):
    gam = [[], []]
    q = 0
    for x in gen:
        q = q + 1
        if q &gt; 1:
            gamgam = gam[:]
            for z in gam: 
                gamgam.append(z)
            gam = gamgam[:]
        for y in range(len(gam)):
            if y &lt; len(gam)/2:
                gam[y].append(x[0])
            else:
                gam[y].append(x[1])
    return gam
</code></pre>

<p>When I execute </p>

<pre><code>gene_erator2([['A','a'], ['B','b'], ['X','Y']])
</code></pre>

<p>I get</p>

<pre><code>[['A', 'B', 'b', 'X', 'X', 'Y', 'Y'], ['a', 'B', 'b', 'X', 'X', 'Y', 'Y'], ['A', 'B', 'b', 'X', 'X', 'Y', 'Y'], ['a', 'B', 'b', 'X', 'X', 'Y', 'Y'], ['A', 'B', 'b', 'X', 'X', 'Y', 'Y'], ['a', 'B', 'b', 'X', 'X', 'Y', 'Y'], ['A', 'B', 'b', 'X', 'X', 'Y', 'Y'], ['a', 'B', 'b', 'X', 'X', 'Y', 'Y']]
</code></pre>

<p>instead of the expected</p>

<pre><code>[['A', 'B', 'X'], ['a', 'B', 'X'], ['A', 'b', 'X'], ['a', 'b', 'X], ['A', 'B', 'Y'], ['a', 'B', 'Y'], ['A', 'b', 'Y'], ['a', 'b', 'Y']]
</code></pre>

<p>....What? I mean, just What?</p>

<p>EDIT:
I now know the function that does what I want thanks to Shang, but I still want to know what was wrong with my code....</p>
