AnsweredAssumed Answered

How to delete fields based off of another layer's fields?

Question asked by ziegenf2 on Apr 28, 2016
Latest reply on Apr 28, 2016 by esarow-esristaff

Hi All,


I am trying to compare the fields of two layers and delete any that are different. This is the code that I thought would work, but it returns RuntimeError: Object: Error in executing tool. Any ideas?


import arcpy

List = arcpy.ListFields("Layer 1")
x = arcpy.ListFields("Layer 2")

for i in x:
    if i in List:
        print i
        arcpy.DeleteField_management("Layer 2", I)