# Remove Item at index error in python

**URL:** <https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449>\
**Category:** Developers\
**Created:** [March 26, 2018, 6:45pm UTC](https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449 "2018-03-26T18:45:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fathygad](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/fathygad/32/42613_2.png) [@fathygad](https://forum.dynamobim.com/u/fathygad)\
**Post date:** [March 26, 2018, 6:45pm UTC](https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449/1 "2018-03-26T18:45:36Z")

</div>

using RemoveItemAtIndex in python gives me this error ??

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/e/ae57d696c0d19c71d1173864b1dd1ba326228900.png)

```
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('DSCoreNodes')
import DSCore 
from DSCore.List import *

pts = IN[0]
out = []

OUT = DSCore.List.RemoveItemAtIndex(pts,1)
```

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [March 27, 2018, 4:44am UTC](https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449/2 "2018-03-27T04:44:33Z")

</div>

Hi @fathygad

You can remove items in a list this way also:

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

---

<div class="post-metadata">

**Author:** ![fathygad](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/fathygad/32/42613_2.png) [@fathygad](https://forum.dynamobim.com/u/fathygad)\
**Post date:** [March 27, 2018, 7:21am UTC](https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449/3 "2018-03-27T07:21:38Z")

</div>

hi @Kulkul  
thanx for this, however i need it to be inside as the index will be get by for loop inside Python script , i tried list.pop(index) and get the new list but it didn’t fulfill my need.

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [March 27, 2018, 7:26am UTC](https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449/4 "2018-03-27T07:26:06Z")

</div>

Can you show me screenshot of your list and what type of result you would like to get.

---

<div class="post-metadata">

**Author:** ![Simony](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@Simony](https://forum.dynamobim.com/u/Simony)\
**Post date:** [April 8, 2020, 11:52am UTC](https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449/5 "2020-04-08T11:52:23Z")

</div>

Hi,  
I’m digging this post because I’d like to dig deeper.  
I have almost the same problem but with sub-lists.  
I’ve written what I’d like to get in green.

 ![Image1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/7/67eb2099ed8ae12f7e9788f6970ba4aeecf82cbb.jpeg)

---

<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:** [April 8, 2020, 1:03pm UTC](https://forum.dynamobim.com/t/remove-item-at-index-error-in-python/20449/6 "2020-04-08T13:03:32Z")

</div>

You doubled up on your lists for the indices. Your codeblock is already a single list (correct structure) before you wrap it in a list again (incorrect structure). You also need to append your outputs for each sublist.

But more importantly your code is just not doing what you want. Right now you’re telling it to remove the sublist `l` from the input list `Lst`. You’re not even using the indices.
