Drop multiple items from sub-list?


#1

Hi,
Is there anyway to drop multiple items from a sub-list? I’m trying to take the first and last item away from a 2 layer sub-list. Thanks


#2

Either a custom function or by doing them sequentially with longest lacing instead of shortest.


#3
thelist = IN[0]
indices = IN[1]

indices.sort(reverse = True)
outList = []
for i in indices:
	if isinstance(thelist,list):
		for j in thelist:
			if isinstance(j,list):
				templist = []
				templist.append(j.pop(i))
			else:
				continue
			try:
				outList.append(templist)
			except:
				outList.append("Check input list")

OUT = thelist

Quick script until it is figured out how to be done in nodes. Takes a list of lists and then a list of indices. Will only go one level deep so if it needs to be deeper, has to be reworked. In addition, order of indices doesn’t matter. If there is some problem with the outcome, change OUT to OUT = thelist,outList and go through the second list to see where there was a problem.


#4

Springs has a Node for this. Springs.List.DropFirstLast


#5

OOTB node only: