List replace item at index

Hi Forum

I have searched the forum and looked at every topic on this subject but I cannot find an example to solve my issue, which I think should be simple.
I would like to replace the 00 in the list with GROUND from another list with the same index value. I have used the AllIndicidesof node to get the index 2, but I cannot seem to find the best node to replace the value. All of the nodes for List.replaceItemAtIndex (also the Clockwork one) do not give the result I need.

The result in this case should be

  1. GROUND

Any thoughts would be greatly appreciated.

Many thanks
Tim

Apologies, my example list should be:

  1. GROUND

Thanks!

Hi Forum

I seem to do this, as soon as I post an idea comes to me. Here is the solution I have worked up…

Seems to work well.
Many thanks
Tim

Hi Tim,

See a more simple solution below:

Hope it helps,
Jake

1 Like

Hi Jake

Many thanks for looking at this. This is not quite what I need, it is the 3 index list I am looking to update, not the full list of levels. But the technique is great, I will see if I can use the IF statement approach.

Many thanks
Tim

Hi Tim,

Apologies I missed that!

In which case I would go down the dictionary route as below:

Not sure why your initial list has 3 entities but 2 are empty? Might be worth cleaning that data before doing a check with it. I did the inverse and just extracted the element from the list to feed into the Dictionary.ValueAtKey (the non erroring node).

Hope this solves your issue!

Thanks again Jake!

I really need to get more familiar with the Dictionary approach. Thank you. Part of this challenge for me is to maintain the list structure with the blank data as this is key for the following stages in the graph. Essentially it is concating a long string together, and it could be blank or filled out, but the list structure needs to remain.

Thanks again, I will give Dictionaries a go. Cheers

1 Like

No problem at all Tim,

Best place to go to learn this stuff is always the primer:
https://primer.dynamobim.org/09_Dictionaries/9_Dictionaries-In-Dynamo.html

Secondly - If you wish to keep the list structure with the empty strings that is no issue. Just include a like for like empty string (β€œβ€) Key/Value pair in the dictionary values like below. This makes the initial node in my screengrab not error

[β€œB2”,β€œB1”,β€œ00”,β€œ01”,β€œ02”,β€œβ€];
[β€œBase1”,β€œBase2”,β€œGround”,β€œFirst”,β€œSecond”,β€œβ€];

All the best,
Jake

1 Like

Hi Jake

This is a very nice way to solve the issue, thank you very much indeed for your help.

Much appreciated!
Best
Tim

1 Like