GIS Pro - Python and Arcade Labeling

1034
2
Jump to solution
11-16-2018 07:39 AM
ChrisGoessl
New Contributor III

We are attempting to do a simple if/else statement for labeling on a project but keep coming up with an error. The code is as follows:

def FindLabel ([Name], [Type]):
   if [Type]= 'Church':
      return "Church"
   else:
      return "Not Church"

The error that we are getting is as follows:

Invalid Expression

Error 0 on line 0

   File "<string>", line 2

      if esri_1 = 'Church':

               ^         

SyntaxError: invalid syntax

We also worked on arcade (New to us). Here is that code:

if DomainName($feature, 'Type' ="Church") {
return $feature.Name
}
else {
return "Not Church"
}

We get the following error:

Invalid Expression

Error on line 1

Open parenthesis expected.

Any help will be greatly appreciated!

Chris Goessl & Justin Fowler

City of Kettering

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi Chris,

For the python portion, when you check if something is equal to, you will want to specify two equal signs (==).  Ex:

def FindLabel ([Name], [Type]):
   if [Type]== 'Church':
      return "Church"
   else:
      return "Not Church"‍‍‍‍‍

View solution in original post

2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Chris,

For the python portion, when you check if something is equal to, you will want to specify two equal signs (==).  Ex:

def FindLabel ([Name], [Type]):
   if [Type]== 'Church':
      return "Church"
   else:
      return "Not Church"‍‍‍‍‍
ChrisGoessl
New Contributor III

ohhhhhhh.... I completely FORGOT about that. That's what happens when you switch between four different computer languages.

0 Kudos