I am using below code to remove any layer if it has zero features in it.
mxd = arcpy.mapping.MapDocument("CURRENT")
aDF = mxd.activeDataFrame
namE = ["No_Work_Done"]
if int(arcpy.GetCount_management(namE[0])[0]) < 1:
try:
arcpy.mapping.RemoveLayer(aDF, namE[0])
except Exception as d:
print(d.message)
else:
print("No Work Done or Conflict Present in Data\n")
However this is returning run-time error and assertion error as below
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\utils.py", line 182, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\mapping.py", line 1845, in RemoveLayer
assert isinstance(remove_layer, Layer)
AssertionError
What could be the problem here?