# Replace every other occurence in list

**URL:** <https://forum.dynamobim.com/t/replace-every-other-occurence-in-list/64225>\
**Category:** Lists-Logic\
**Created:** [May 21, 2021, 3:59pm UTC](https://forum.dynamobim.com/t/replace-every-other-occurence-in-list/64225 "2021-05-21T15:59:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyle](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lyle](https://forum.dynamobim.com/u/lyle)\
**Post date:** [May 21, 2021, 3:59pm UTC](https://forum.dynamobim.com/t/replace-every-other-occurence-in-list/64225/1 "2021-05-21T15:59:23Z")

</div>

Hello fellow Dynamo users!!

I’m stuck on this little list manipulation. I have a list of 0’s, 1’s, and 2’s (green list below). What I need done is whenever the number 1 appears a 2nd, 4th, 6th, etc. time in the list I’d like it to change to the number 3 (pink list below). The lists could get really long and the 1’s can appear at any index.

After the list has the 3’s in it I’ll be able to use IF commands for all the 1’s, 2’s, and 3’s to trim curves by TrimByEndParameter(1’s), TrimByParameter(2’s), and TrimByStartParameter(3’s).

 ![List help_2021-05-21_10-33-39](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d36b2d0a7d15eac2d663d149dd0fd9ab43d5feea.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 21, 2021, 4:38pm UTC](https://forum.dynamobim.com/t/replace-every-other-occurence-in-list/64225/2 "2021-05-21T16:38:44Z")

</div>

You could do this really quickly with python. Just have a boolean check on whether you’re on a first or second 1.

It’s should also be doable with OotB nodes, but will take a bit of list management. I would start with getting all indices of 1 and then converting every other index to 3 to place back in the original list.

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [May 21, 2021, 4:45pm UTC](https://forum.dynamobim.com/t/replace-every-other-occurence-in-list/64225/3 "2021-05-21T16:45:59Z")

</div>

A couple of ways with nodes …

 ![replace_2021-05-21_10-04-50](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/f/4f93da2c5e82c333af83141d6750e1b1ffb240b3.png)

 ![replace_2021-05-21_10-06-51](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/8/88ac3de9d761192955f94a6aab0de3e7c38d417c.png)

[replace.dyn](https://forum.dynamobim.com/uploads/short-url/6Iq9idsyCnFC6e7FCS1d4sihShe.dyn) (45.1 KB)

---

<div class="post-metadata">

**Author:** ![lyle](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lyle](https://forum.dynamobim.com/u/lyle)\
**Post date:** [May 21, 2021, 4:57pm UTC](https://forum.dynamobim.com/t/replace-every-other-occurence-in-list/64225/4 "2021-05-21T16:57:57Z")

</div>

Thank you for the help. I completely forgot about list.transpose. There are so many nodes that I’m bound to for get another simple one.
