Let's say I wanted to get all the possible combinations of three binary digits, i.e:
0,0,0
0,0,1
0,1,0
0,1,1
1,0,0
1,0,1
1,1,0
1,1,1
I could do something like this:
p = []
for a in range(2):
for b in range(2):
for c in range(2):
p.append([a,b,c])
print p
But what if I wanted to define a function that returns the possiblities for n numbers of binary digits? i.e. How can I stack the for loops dynamically?