Search code examples
pythonbinarypython-itertools

Generate Binary Table with Itertools


So this is what im trying

list(itertools.combinations_with_replacement('01', 2))

but this is generating [('0', '0'), ('0', '1'), ('1', '1')]

I still need a ('1','0') tuple, is there a way to make itertools also do combinations and order?


Solution

  • Use

    list(itertools.product(*["01"] * 2))
    

    instead.