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?
Use
list(itertools.product(*["01"] * 2))
instead.
To take the cartesian product of a value with itself, you use
itertools.product("01", repeat=2)
This will give you all possible combinations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With