AnsweredAssumed Answered

if field.name in fieldList

Question asked by BTLeslie on Sep 23, 2014
Latest reply on Sep 23, 2014 by ad_giles@hotmail.com

Hi

I'm trying to do a script that will search a bunch of features and tell me if they contain a certain field name or not:

 

fcs = arcpy.ListFeatureClasses()

for fc in fcs:
     fieldList = arcpy.ListFields(fc)
     if "CAT" in fieldList:
          print fc + " Yes"
     else:
          print fc + " Nope"

 

I think I've figured out that I somehow need to tell it is look for "CAT" as a field name in fieldList but I'm not sure how to write it.

I've tried a few things such as:

     if "CAT" in fieldList.field.name

but I haven't hit upon the correct syntax.

 

Can you help?

 

(just thought I'd add that everything comes out as "Nope", which isn't correct, using the above code)

Outcomes