In Python how do I create variable length combinations or permutations?
问题 Lets say I have an array called arr = [1,2,3,4] How can I generate all the possible combinations with minimum 2 arguments that end up looking like [1,2] [1,3] [1,4] [1,2,3] [1,2,4] [1,2,3, 4] [2,3] [2,4] and so on and so forth? Nothing Im trying works. I cant seem to use itertools.combinations or permutations because I need to know the argument size and I cant seem to use itertools.products because that will take minimum one argument from each of a list of lists that looks like this [[1],[2],