Help with script dynamo and families from lines

I think i recogize the problem from a facebased family. May you can find a soluction here:

It is with python for me it did not work i need to add a loop and python is not mine first lanluage :smiley: