Remove Item at index error in python

using RemoveItemAtIndex in python gives me this error ??

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)

Hi @fathygad

You can remove items in a list this way also:

1 Like

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.

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

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.

1 Like

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.