# How to replace nested lists?

**URL:** <https://forum.dynamobim.com/t/how-to-replace-nested-lists/55745>\
**Category:** Uncategorized\
**Created:** [October 1, 2020, 2:46am UTC](https://forum.dynamobim.com/t/how-to-replace-nested-lists/55745 "2020-10-01T02:46:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pschelechow\_MPS](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Pschelechow\_MPS](https://forum.dynamobim.com/u/Pschelechow_MPS)\
**Post date:** [October 1, 2020, 2:46am UTC](https://forum.dynamobim.com/t/how-to-replace-nested-lists/55745/1 "2020-10-01T02:46:41Z")

</div>

I’m not sure if I’ve phrased the question correctly, but I’m wondering if it is possible to replace selected indices within a nested list as shown in the image I have included. So far, I don’t seem to be able to replace the five sublists within the main list.

Thank you in advance for any help!

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/f/1f717afef45a3c50d62460a434bb8840bacc584b.png)

---

<div class="post-metadata">

**Author:** ![blsalvio](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@blsalvio](https://forum.dynamobim.com/u/blsalvio)\
**Post date:** [October 1, 2020, 4:10am UTC](https://forum.dynamobim.com/t/how-to-replace-nested-lists/55745/2 "2020-10-01T04:10:22Z")

</div>

hi @Pschelechow_MPS

try this script [replace\_at\_index.dyn](https://forum.dynamobim.com/uploads/short-url/9bAEhWJFnUb619ShUBrWgk5yvkt.dyn) (6.1 KB)

![a](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/d/8dd4d494b2ee787a9347675cb8c6a6227c550b4b.png)

---

<div class="post-metadata">

**Author:** ![Pschelechow\_MPS](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Pschelechow\_MPS](https://forum.dynamobim.com/u/Pschelechow_MPS)\
**Post date:** [October 1, 2020, 1:17pm UTC](https://forum.dynamobim.com/t/how-to-replace-nested-lists/55745/3 "2020-10-01T13:17:39Z")

</div>

This is fantastic! Thank you so much for your help! This is exactly what I was attempting to accomplish.

I feel fairly inept especially since the code looks so simple. Is there a particular reason that the native node in dynamo for “list replace item at index” doesn’t perform in the same way?

---

<div class="post-metadata">

**Author:** ![blsalvio](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@blsalvio](https://forum.dynamobim.com/u/blsalvio)\
**Post date:** [October 1, 2020, 11:41pm UTC](https://forum.dynamobim.com/t/how-to-replace-nested-lists/55745/4 "2020-10-01T23:41:57Z")

</div>

Hi @Pschelechow_MPS

The node `List.ReplaceItemAtIndex` I think only replaces an item once at a time that is why it does not behave the way you want it to behave.

-biboy
