0

I am trying to use a check a field against several values (eg: [Name] != 'NONE', and [Name] != 'N/A'). This is for the label expression builder within ArcGIS and I am using it eliminate label for fields with NONE, @ or other invalid fields.

I have tried:

def FindLabel ([Name]):
      if [Name] != 'NONE' or [Name] != 'N/A':
         return None
      elif:
         return [Name]

I also tried separating these out:

def FindLabel ([Name]):
     if [Name] != 'NONE':
        return None
     elif [Name] != 'N/A':
        return None
     elif:
        return [Name]

The above results in the labels being printed for the invalid values still despite the if loops.

Is there a way to check a value against a list and eliminate labels, while printing those for valid values?

  • 1
    You are checking if the fields are NOT 'NONE' or 'N/A' and then returning None... Shouldn't you be checking if it IS 'NONE' or 'N/A' ? – BruceDoh Jul 28 '15 at 13:09
2

The code that works for this problem is:

def FindLabel ([Name]):
     if [Name] not in ['NONE','N/A']:
          return [Name]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.