Help with basic levels in Python

How can make this work in python?

image

Actually I am trying to convert my nodes to python script,I am kind of struck here.

here is how my current script looks like.

final_points=projected_unique_points_base
final_curves=new_final_curve
#------------------------------------------------------
bounding_box_curve=[]
for i in final_curves:
	bounding_box_curve.append(BoundingBox.ByGeometry(i))


for i in bounding_box_curve:
	for j in final_points:
		result.append(BoundingBox.Contains(i,j))

This code gives a flattened list instead of maintaining a list structure,I wanted to ask python to create a new sublist everytime all i are

Try indenting the second half under the first. This way all the looping should stay nested together.

like this ?

#-----------------------------------------------------
final_points=projected_unique_points_base
final_curves=new_final_curve
#------------------------------------------------------
bounding_box_curve=[]
result=[]
for i in final_curves:
	bounding_box_curve=BoundingBox.ByGeometry(i)
	for j in final_points:
		result.append(BoundingBox.Contains(bounding_box_curve,j))
		
OUT = result

Didn’t work though.!
here is what it returns vs what I wanted.

Maybe something like that :

result=[]
for i in final_curves:
	bounding_box_curve=BoundingBox.ByGeometry(i)
	curves=[]
	for j in final_points:
		curves.append(BoundingBox.Contains(bounding_box_curve,j))
	result.append(curves)
		
OUT = result

You can also put it inside a Custom Node to leverage List@Levels :slight_smile:

It looks like it’s just a list structure issue? In which case I think you need another list to append to.
It would look something like this:

primary_list = []
for a in b:
    secondary_list = []
    for c in d:
        secondary_list.append(your_output_here)
    primary_list.append(secondary_list)
out = primary_list

This gives a correct list structure but, the count of each sublist is equal to count of final_points but I am looking at sublist count = final_curves count.