I have 4,018 rows of data with about 50 fields. About 45 of those fields are the same variable, but the data came from different layers, so out of those 45 fields, only one has a value for the row, the rest are null. I just need the actual value in my final field. I used a string wildcard to identify the right fields. This code returns NULL for every row.
def n():
import arcpy
fields = arcpy.ListFields('Extract_fires')
for f in fields:
if f == 'AVGPRE*' and f is not None:
return(f)
f.name == 'AVGPRE*'
definitely doesn't make sense, because asterisk is not a permitted character in field names (alphanumeric and underscore only), so it will never evaluate True. You can test'AVGPRE' in f.name.upper()
to accomplish your goal. TheNone
test is useless, since it will never be False.