AnsweredAssumed Answered

GIS tutorial for Python Scripting written by David Allen

Question asked by jerry47 on Sep 17, 2014
Latest reply on Sep 25, 2014 by jareds22

Please let me know if the below code is right or not. if it is wrong can you please correct it for me.

 

I changed the below code from the above titled book during learning Tutorial 1, which was titled "Use Python in the Label Expression dialog box". I am using ArcGIS 10.1 but the tutorial used ArcGIS 10.2.

 

This is the original code from the text book.

 

def FindLabel ( [OwnerName] ):

  rawName = [OwnerName]

  commaNum = rawName.find(",")

  formatName = rawName[commaNum+2:] + " " + rawName[:commaNum]

  return formatName

 

When I run this above code I have this error "SyntaxError: invalid syntax (<string> , line 4"

 

Can you please let me know the right code to use.

 

I modify it to below code but still experience another error.

 

def FindLabel ( [OwnerName] ):

  rawName = [OwnerName]

  commaNum = rawName.find(",")

  formatName = rawName(commaNum[2:]) + " " + rawName(commaNum[0:]

  return formatName

 

Regards,

Jeremiah.

Outcomes