Algorithm for sublist in python

There’s probably a cleaner way of doing this but a simple use of append will work.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('DSCoreNodes')
from DSCore import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
items = IN[0]
inlist = IN[1]
newlist = []

for indices in inlist:
	sublist = []
	for i in indices:
		sublist.append(items[i])
	newlist.append(sublist)

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