All possibilities permutations of 0 and 1
<p>I want to list all possible permutations of 0 and 1 six times for probability reasons.</p>

<p>I started out like this, thinking, it was a piece of cake; until all combinations are listed the code should keep on randomising the values.
However once 0 and 1 are in the list it stops, i thought "for range in 6" would give something like this:</p>

<p><code>"0,0,0,0,0,0"</code> (which is a possibility of 0 and 1)</p>

<p><code>"1,1,1,1,1,1"</code> (which also is a possibility of 0 and 1)</p>

<p>My current output is "0, 1"</p>

<p>How can I group the items together of pieces of 6 and make the program keep filling values up unless a combination is already in my list?<br>
I know there are 64 combinations altogether because of 2^6.</p>

<pre><code>import math
import random

    a = 63;
    b = 1;
    sequences = [];
    while (b &lt; a):
        for i in range(6):
            num = random.randint(0 , 1)
            if(num not in sequences):
               sequences.append(num)
               b += 1;
            else:
                b += 1;

    print(sorted(sequences));
</code></pre>

<p>I didn't understand if you are looking for a solution, or for a fix for your code. If you just look for a solution, you can do this much easier and more efficiently using <a href="https://docs.python.org/2/library/itertools.html#itertools.product" rel="nofollow"><code>itertools</code></a> like so:</p>

<pre><code>&gt;&gt;&gt; from itertools import *
&gt;&gt;&gt; a = list(product([0,1],repeat=6)) #the list with all the 64 combinations
</code></pre>

python permutation