Reputation: 8322
I'm working on returning all the combinations of a list based on a list of ranges.
So if I have:
test_list = [range(0,11,1),range(0,11,2),range(0,11,5)]
And I want to return a list with all the possible combinations based on the ranges. For Example:
output_list[[0,0,5],[0,0,10],[0,2,0],[0,4,0],[0,6,0].......]
But all I have been able to do is:
import itertools
test_list = [range(0,11,1),range(0,11,2),range(0,11,5)]
output_list = []
for i in itertools.permutations(test_list):
if i not in output_list:
output_list.append(i)
Which returns each range permuted,(a list of ranges again)?
Upvotes: 4
Views: 5598