# L-9 MCS 275 Mon 4 Feb 2008 : enumbits
#
# enumerates all combinations of n bits

def enumbits(k,L):
   """
   writes all bit combinations of len(L),
   starting at the k-th position
   """
   if k >= len(L):
      print L
   else:
      L[k] = 0
      enumbits(k+1,L)
      L[k] = 1
      enumbits(k+1,L)

def main():
   """
   prompts the user for number of bits
   and initializes the list
   """
   n = input('Give number of bits : ')
   L = range(0,n)
   enumbits(0,L)

main()
