Replace multi sublists with multi sublist at index

Hi everyone,

I’m trying to replace the sublists Price and where to buy with another sublist contains other information.

I hope the picture below shows clearly what I want to change.

Thank you very much for your help.

Hi @thongle3103

something like this replace.dyn (12.3 KB)

Hi @blsalvio

Thank you for your help, but currently I’m trying to replace many sublist, not just 2. So it would take a lot time time to do it your way. Is there any other way?

Like this? replace.dyn (12.6 KB)

That’s right, found a previous list right after I posted the topic. Is your code similar to this?

My python code is almost similar but the variables are easy to understand.

Thank you very much for your help. I’ll should to get start with Python I think. Appreciate your help very much!.

Could try this too …

repMul.dyn (6.3 KB)

def RepMul (lst:var[]..[],ind:var[]..[],itm:var[]..[])
	return [Imperative]
		a = [];
		c = -1;
		for (i in ind)
			c = c + 1;
			a = List.ReplaceItemAtIndex(lst,i,itm[c]);
			lst = a;
		return a;

RepMul (lst,ind,itm);

A dictionary would be a good fit for what you are trying to do. With that data structure replacing a set of specific values is really simple.

1 Like