Python- Entry Level Programming
<p>I need to set up a code that has a 50% chance of selecting the first character of the mother string or the first character of the father string and add it to the child string, and so on for each letter. </p>

<pre><code>import random
mama_string = "0&gt;Y!j~K:bv9\Y,2"
papa_string = "OkEK=gS&lt;mO%DnD{"
child = ""

while len(child) &lt; 15:

    random_number = random.randint(0,100)
    if random_number &lt;= 50:
        for mama_char in mama_string:
            child += mama_char
            break

    if random_number &gt; 50:
        for papa_char in papa_string:
            child += papa_char
            break

    print("The mother string is:",mama_string)
    print("The father string is:",papa_string)
    print("The child string is:",child)
</code></pre>

<p>The mother string is: 0>Y!j~K:bv9\Y,2</p>

<p>The father string is: OkEK=gS&lt;
mO%DnD{</p>

<p>The child string is: 0O0O0O0OO0OOO00</p>

<p>You could do it this way:</p>

<pre><code>import numpy as np
counter = 0

while len(child) &lt; 15:
    choice = np.random.choice([0,1])

    if choice == 0:
        child += papa_string[counter]

    else:
        child += mama_string[counter]

    counter += 1
</code></pre>

<p>This will alternate between selecting from the mother and father.</p>

python random iteration