Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Did you try print(list(it.permutations(a, 4)))? Might that be what you're looking for? Commented Aug 19, 2018 at 8:38
  • The last part of your question doesn't agree with your desired output. You say "...that contain original [1, 2, 3, 4] sequence in any order?" For that you would simply reshuffle using something like random.shuffle. What your output is telling me is that you want to randomly pick pairs from list(it.combinations(a, 2)). Could you clarify a bit? Commented Aug 19, 2018 at 9:23
  • 1
    @JosephWood: Sure, let me clarify a bit: I need to get all sets of n-tuples such that their members contain all the population of original list, when the order within an n-tuple does not matter. Thus [(1, 2), (3, 4)] is ok, but [(2, 1), (3, 4)] is not needed because it is the same as the first set, if we ignore the order Commented Aug 19, 2018 at 9:51