python:assignment of list item as true and false
Question: I have a Python list and I want to assign all possible combinations of `True`
and `False` values to all the elements of the list.

Suppose I have list `list1 = ['a', 'b']`, so I want a new list as
`[['t','t'],['t','f'],['f','t'],['f','f']]`, which are all the possible
combinations of `True` and `False` value of the given list item.

If I have `n` element in the given list then I should `2^n` element in my new
list and each of the inner lists should contain `n` element either as 't' or
'f'.

How can I achieve this?


Answer: Use `itertools.product`.

    
    
    >>> import itertools
    >>> list(itertools.product(["t", "f"], repeat=2))
    [('t', 't'), ('t', 'f'), ('f', 't'), ('f', 'f')]
    >>> list(itertools.product(["t", "f"], repeat=3))
    [('t', 't', 't'), ('t', 't', 'f'), ('t', 'f', 't'), ('t', 'f', 'f'), ('f', 't', 't'), ('f', 't', 'f'), ('f', 'f', 't'), ('f', 'f', 'f')]
    >>> #etc
    

