# List get item at index fails

**URL:** <https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617>\
**Category:** Uncategorized\
**Tags:** excel, dynamo\
**Created:** [December 22, 2020, 4:11pm UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617 "2020-12-22T16:11:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sven\_de\_leau](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Sven\_de\_leau](https://forum.dynamobim.com/u/Sven_de_leau)\
**Post date:** [December 22, 2020, 4:11pm UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/1 "2020-12-22T16:11:31Z")

</div>

Goodday,

Today i ran across an warning in one of our dynamo scripts which hasn’t occured before.  
Used the script multiple times before without any warnings.  
First screenshot is the working version, Second one contains the warning.  
Any solutions?

 ![splitting lists 1-2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/1/218a09ad84791e1398aae5a12d251f257629a14e.jpeg)  
 ![splitting lists 2-2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/59feb0b00f84631f45261b9cc5bfab2fdca66244.jpeg)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [December 22, 2020, 6:22pm UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/2 "2020-12-22T18:22:23Z")

</div>

Have you just tried replacing the node?

---

<div class="post-metadata">

**Author:** ![daniel1](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@daniel1](https://forum.dynamobim.com/u/daniel1)\
**Post date:** [December 22, 2020, 8:20pm UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/3 "2020-12-22T20:20:16Z")

</div>

Try removing the nested empty lists from the List.AllIndicesOf Node.

---

<div class="post-metadata">

**Author:** ![Sven\_de\_leau](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Sven\_de\_leau](https://forum.dynamobim.com/u/Sven_de_leau)\
**Post date:** [December 23, 2020, 7:55am UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/4 "2020-12-23T07:55:19Z")

</div>

@Alien Tried, but it didn’t work

---

<div class="post-metadata">

**Author:** ![Sven\_de\_leau](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Sven\_de\_leau](https://forum.dynamobim.com/u/Sven_de_leau)\
**Post date:** [December 23, 2020, 7:56am UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/5 "2020-12-23T07:56:55Z")

</div>

@daniel1 I want to keep the empty lists for the structure of the whole list, otherwise i have to find a way around it to reorganize the list

---

<div class="post-metadata">

**Author:** ![daniel1](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@daniel1](https://forum.dynamobim.com/u/daniel1)\
**Post date:** [December 24, 2020, 12:49am UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/6 "2020-12-24T00:49:11Z")

</div>

From my experience, the List.GetItemAtIndex node typically errors out when it is fed with nested empty lists. I would restructure the graph in order to prevent the issue. Without seeing all of the nodes and dropdown previews I can only offer a few bits of advice.  
Input the List.AllIndicesOf node into a flatten node and a count node at level two. Input the flatten node and the count node into a chop node to reproduce the original structure without the empty lists.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [December 24, 2020, 1:46am UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/7 "2020-12-24T01:46:16Z")

</div>

> [@daniel1](#):
>
> List.GetItemAtIndex node typically errors out when it is fed with nested empty lists

Most nodes will fail this way when given an empty list as the first item. It’s always best to clean your data or account for the issue as you go.

3 off the top of my head options to deal with the bad data:

1. Use a List.Map method or a Function.Apply method to force the full list to process despite the error. Careful as someday this could suppress a “stop the presses” warning you would want surfaced.

2. Build up the list by adding value which will fail but will ensure continued processing via forcing List Levels, a String may work in this case. Careful as this is effectively ensuring a warning in all cases.

3. Add a list of [0] and an index of 0 to the larger data structure, ensuring the first attempt at ItemAtIndex always has valid input, and then remove the resulting initial zero from the result. Careful as this could become a repeat process that will slow the graph down on big data sets by adding new lists into the memory.

4. Revisit the larger structure of the graph and/or workflow. Hard to know how much this would entail with the data given. This is likely the most likely but will also require the most soul searching on your end (both for you and anyone else who may be consuming the workflow).

---

<div class="post-metadata">

**Author:** ![Sven\_de\_leau](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Sven\_de\_leau](https://forum.dynamobim.com/u/Sven_de_leau)\
**Post date:** [March 29, 2021, 7:15am UTC](https://forum.dynamobim.com/t/list-get-item-at-index-fails/58617/8 "2021-03-29T07:15:51Z")

</div>

Recently updated to Revit 2021, Issue seems to be fixed in Revit 2021, All nodes i’ve used in dynamo seem to work when they’re fed with nested empty listst. Huge relief for my dynamo scripts.
