[GIS] Deleting Feature Class from Geodatabase using list in ArcPy

arcpyfeature-classfile-geodatabase

I am trying to delete several feature classes from a file geodatabase using values stored in a user defined list.

The script runs without error but it does not delete the feature classes.

Any suggestions to what I am doing wrong (using ArcMap 10.3)?

import arcpy

arcpy.env.workspace = r"C:\Data\Temp.gdb"

fc_Delete = ["fcOut1a","fc_Out2a","fc_Out3a"]

for fc in fc_Delete:
    if arcpy.Exists(fc):
        arcpy.Delete_management(fc,"")

Best Answer

Your code is correct, however I would remove the empty string part of the arcpy delete function.

ie:

arcpy.Delete_management(fc)