I\'ve generated a list of combinations, using itertools
and I\'m getting a result that looks like this:
nums = [-5,5,4,-3,0,0,4,-2]
x = [x for x
You can use itertools.combinations_with_replacement().
Return r length subsequences of elements from the input iterable allowing individual elements to be repeated more than once.
Combinations are emitted in lexicographic sort order. So, if the input iterable is sorted, the combination tuples will be produced in sorted order.
Elements are treated as unique based on their position, not on their value. So if the input elements are unique, the generated combinations will also be unique.
Source: Python Docs