ReplaceItematindex don't work

hi
i have some issues with the replacement of item at index. do you have any idea where is the problem ?

Just so there is not misunderstanding, in this regard you are replacing a list with another list and not individual items of each list. Case in point, if 3 was one of your indices, you would be replacing the 3 items with 4 items and not just replacing the first 3 items in the original list with the first 3 items from the replacement list. You may already know that and that is what you are after, but I thought it should be mentioned anyway.

Also, the replaceitem node will cycle the main list per the number of indices listed. So it will cycle twice in your example. If you leave the levels and lacing alone, the replaceitem node fires off correctly.

First cycle it replaces the list at index 2.

Second cycle it replaces the list at index 4.

From that point, not sure how you would merge the two list into one. You may have to create custom code block to handle the whole process.

Try changing the replacement list level to @2 since you want to replace with the whole list. Also, if you don’t absolutely need it, you’d be better off removing the additional list level in your main list. Otherwise it’s going to affect the natural lacing of the node.

Keep in mind that at some point list levels won’t be able to provide the level of control you want based on a given list structure. It’s always better to have a list structure that matches perfectly between inputs (no list levels needed). The farther you get away from this, the more likely you are to run into issues.

I’m grateful for your assistance, but your method only works for two indexes. However, if I have more indexes (perhaps 50), I might be able to have 50 lists.

If you have that many indexes, lists, and items, replace item at index is likely a bad workflow. I recommend posting the larger graph and explaining the logic, as if there is a better workflow you’ll benefit from it by having a faster graph and learn something to boot.

Exactly. That’s why I mentioned about the cycling being based on the number of indexes you are changing and the fact that you may have to resort to custom coding with python to handle what you are after. So with that, I would recommend following @jacob.small advice.