field calculator error

528
2
Jump to solution
07-25-2014 09:56 AM
LefterisKoumis
Occasional Contributor III

I am novice in python and I am trying to run a function in the field calculator and I get this error. It drives me nuts. What is wrong?

Thank you.

Error:

error 000539: syntaxerror: invalid syntax (<expression>, line 1)

Pre-Logic Script Code:

def fnfindstation(addstation):

  if addstation == "151" or addstation == "551":

   formataddress ="Oleander Station 1 - Shift B"

  elif addstation == "152" or addstation == "552":

    formataddress ="Oleander Station 2 - Shift B"

  else:

    formataddress = "Outside Station"

  return formataddress



Station =
fnfindstation=( !district!)

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
IanMurray
Frequent Contributor

since you are calling a function on a field, there is no need for an equal sign, since you are not setting a variable in your expression.

instead of

fnfindstation=( !district!)

try

fnfindstation(!district!)

View solution in original post

0 Kudos
2 Replies
IanMurray
Frequent Contributor

since you are calling a function on a field, there is no need for an equal sign, since you are not setting a variable in your expression.

instead of

fnfindstation=( !district!)

try

fnfindstation(!district!)

0 Kudos
LefterisKoumis
Occasional Contributor III

Huh... I knew it was something simple.. has to get used to Python since it is so different that other languages. Thank you.

0 Kudos