Replace item at index


I’m having an issue working with lists. I’m trying to replace a value given an index. However I’m not sure why, but it doesn’t seem to be behaving like I expected. I’ve tried changing the lacing to no avail. I’ve attached some snaps of the definition, the definition file and the Revit file.

Basic Test 1.rvt (12 KB)
Sound_Params_V1.dyn (12.7 KB)

I would appreciate whether you think this is a good way of solving the problem as well, I’ve seen lot’s of topics to do with list logic in this field and I could do with knowing a good way of solving this. Some of the posts I’ve been looking at today are as follows.

[What if you have more than 1 if statement?]


What is the outcome of this task?


I’m going to write those numbers (13,5,9 for example) back into a room parameter later down the line. That later section I know how to do.

I’ve also noticed I was missing a item for index 3. That is now sorted.


So if I understand correctly, wherever you see a 3 for instance in your list flatten that you tie into “index” you want it to return a “nah m8” or some value you specify correct?

1 Like

is your lists jagged?

maybe my nodes can help you

or maybe the list index nodes

1 Like

Tell me if I am understanding this right:
The list of parameter values at the top, you want it changed to either 13, 5, 9, or “nah m8” based on the flattened list in the same index?

If that is true, is there any need for using the parameter value list as an input? Can’t you just replace what is in the flatten list with the 13, 5, 9, etc and use that instead? Isn’t it the same thing?

1 Like

I could not manage to open you sample revit file, so I had to make my own…

Is it something like this you want?
Sound_Params_V1.dyn (12.2 KB)

indicies = IN[0]
replacements = IN[1]

t = []
for index in indicies:

OUT = t
1 Like

Yes that is correct.
I didn’t need to use that parameter value list. I thought I would have to give it a sequence 7 long to feed into that node.

I understand there will be a few different ways of doing it, and would like to know ones that reduce computing power required.

Thanks for your reply.

This is what I wanted thank you. I’ve only just seen your other two solutions but I think this one looks to be simpler to set up.

I think it’s about time I started learning python.

Sorry about the Revit file not working…
Tusen takk.


Would this work?


sure this works @kennyb6… much better :wink:

please mark the solution you find most suited as the solution… I do know that you by this will end i troubles, since your question needed two things to be fixed (the “replace empty lists” and the “replace at index” issue).


That worked as well thank you.