If I have a list, say
a=[1,2,3,4]
I want to specify a length, let's say 3, then I can find all the subsets:
[[1,2,3],
[1,2,4],
[2,3,4]]
Does Python has a function so that I can do this quickly?
If I have a list, say
a=[1,2,3,4]
I want to specify a length, let's say 3, then I can find all the subsets:
[[1,2,3],
[1,2,4],
[2,3,4]]
Does Python has a function so that I can do this quickly?
You can do this:
import itertools
print(list(itertools.combinations(your_set, length_of_subsets)))