Partitioning Items into Sub-lists based on list lengths. (Custom Python Code)

@KiranGolla.BLOX If you don’t want to introduce any new variables then try this:

# The inputs to this node will be stored as a list in the IN variables.
Parts = IN[1]
Items = IN[0]

# Place your code below this line
List = []

for i in range(len(Parts)):
	Temp = []
	A = 0
	for j in Parts[i]:
		if j == 0:
			x = []
		else:
			x = Items[i][int(A):int(A+j)]
			A = j
		Temp.append(x)
	List.append(Temp)

# Assign your output to the OUT variable.
OUT = List
1 Like