Python. Add a sublist that starts with a word to the following sublists and repeat from each time a sublist starts with word appears

Hello,

I do those things with OOTB nodes easily as drinking water but I need to do it in Python because computer crashes if the original list is massive.

I need to Add a sublist that starts with a word to the following sublists and repeat from each time a sublist starts with word appears, and finally remove the sublists that have been added to the other sublists.

This is how is done with OOTB nodes, screenshot:


and the dynamo file for testing:
addsublisttofrontifsublistcontainsstring.dyn (25.6 KB)

I’ll leave this one to a colossal oneliner this time, haha.

1 Like

May thanks for your help, all working well. I am sure it is possible with a line but happy with anything that achieves the result even 100 lines needed, but I do not have a clue how to do it in one way or another on Python! :sweat_smile:

@ruben.romero Here you go: Python - addsublisttofrontifsublistcontainsstring.dyn (7.7 KB)

2 Likes

awesome as always, so simple like that and with nodes it is a nightmare that maybe it is not going to work in any moment

2 Likes