Im trying to iterate through all possibilities of a list, where the size of the resulting lists can be greater than the size of list of variables.
For example, if given ([1,-1], 3) the result would be:
[1,1,1], [1,1,-1], [1,-1,1], [1,-1,-1], [-1,1,1], [-1,1,-1], [-1,-1,1], [-1,-1,-1]
My code for this was using itertools but the function only outputted a fraction of what was actually supposed to be outputted. My code:
def perms(list1, size):
for permutation in itertools.combinations_with_replacement(list1, size):
print(permutation)