Hello, I’m using Itertools in python to give a series of permutations out. However, its outputting the numbers as sets of strings in a list. I’m wondering if there is a way to make the numbers into a grafted list?

Starting from what you already have, you can probably do this:

from itertools import combinations_with_replacement
from ghpythonlib import treehelpers
combinations = combinations_with_replacement(xrange(x+1), y)
nested_combinations = []
for comb in combinations:
if sum(comb) == x and comb[0] > 0:
ncomb = []
for num in comb:
ncomb.append([num])
nested_combinations.append(ncomb)
a = treehelpers.list_to_tree(nested_combinations)