Loop Statement not working

I want to have this take in a single surface, areas, and directions and output Surfaces that match each area.

I can get the code to split the initial surface once, but i havent been able to get it to loop correctly for the remainder of the surfaces.

I also need to get the last area added to the list, i assume that needs to be done with an if statment of some sort but i have no idea what the condition woud be.

Would I be better served with a While Loop over the For Loop?

Thank you,

This might be a better visual for what I am trying to accomplish.

Thanks,

I’m getting closer to what I need to achieve.

After a bit of testing I have realized that the first line inside my while loop is returning a null, even though outside of the loop it works normally.

Does anyone know what is goin on here?

Thank you,

I worked out my issue by creating a custom node that preformed the task that I needed done and running it through a LoopWhile Node. Just like this example.

Here is the graph I ended up creating

And here is the custom node I created

Hopfully this will be of some use to the next person to stumble across this post.