# Looping a differenz between Items in a List

**URL:** <https://forum.dynamobim.com/t/looping-a-differenz-between-items-in-a-list/43355>\
**Category:** Lists-Logic\
**Tags:** loop\
**Created:** [November 19, 2019, 1:35pm UTC](https://forum.dynamobim.com/t/looping-a-differenz-between-items-in-a-list/43355 "2019-11-19T13:35:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alejandre](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alejandre](https://forum.dynamobim.com/u/alejandre)\
**Post date:** [November 19, 2019, 1:35pm UTC](https://forum.dynamobim.com/t/looping-a-differenz-between-items-in-a-list/43355/1 "2019-11-19T13:35:01Z")

</div>

Hi to everybody,

As you can see in the pic, I am trying to rest the second Item of a list with the first one, then… the third one with the second one… and so, till last item…

It´s possible to create a loop to this operations without writing 200 lines in a codeblock with all the possiblities?

Because, for example I have to create a 20 lines more if the node “count” has a result of 21…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/0/80fe3dc393a39a1ee7befa2c2a2dc22c94684d62.png)

---

<div class="post-metadata">

**Author:** ![khuzaimah.ElecEng](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/khuzaimah.eleceng/32/92768_2.png) [@khuzaimah.ElecEng](https://forum.dynamobim.com/u/khuzaimah.ElecEng)\
**Post date:** [November 19, 2019, 1:38pm UTC](https://forum.dynamobim.com/t/looping-a-differenz-between-items-in-a-list/43355/2 "2019-11-19T13:38:25Z")

</div>

hi,  
first of all, if you are using code block, then use a[0] instead of List.GetItemAtIndex(a,0).

for your case get the list and use List.ShiftIndeices node, and subtract it from the original list

---

<div class="post-metadata">

**Author:** ![alejandre](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alejandre](https://forum.dynamobim.com/u/alejandre)\
**Post date:** [November 19, 2019, 1:51pm UTC](https://forum.dynamobim.com/t/looping-a-differenz-between-items-in-a-list/43355/3 "2019-11-19T13:51:22Z")

</div>

wow @khuzaimah.ElecEng … thank you very much…  
I have modified it… and it works perfect…

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