l = [True, True , False]
Without using itertools
module.
How do yo create permutations of l in a new list
newlist = [[True,True,False],[True,True,True], [False,False,True],[False,False,False]....]
essentially this is what im trying to do:
allorderings = itertools.product ([False, True], repeat = n)
Use itertools.permutations
import itertools
l = [True, True , False]
newlist = list(itertools.permutations(l))
EDIT: from your question, one of the permutations you need is (True, True, True)
which is not a permutation at all of the list l
. This answer gives you permutations of a list in the technical sense and you may have to do extra work to achieve what you show in the question(unless of course that was a typo).
The simplest way I could think of, would be to iterate over the same list of items thrice and collect only the unique items, like this
l = set([True, True, False])
print {(i, j, k) for i in l for j in l for k in l}
Use itertools.permutations
's equivalent in pure python from the official docs?
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